Blame SOURCES/gdb-test-expr-cumulative-archer.patch

b94e32
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
b94e32
From: Fedora GDB patches <invalid@email.com>
b94e32
Date: Fri, 27 Oct 2017 21:07:50 +0200
b94e32
Subject: gdb-test-expr-cumulative-archer.patch
b94e32
b94e32
;; [archer-keiths-expr-cumulative+upstream] Import C++ testcases.
b94e32
;;=fedoratest
b94e32
b94e32
archer archer-keiths-expr-cumulative
b94e32
b5a7497340b24199f0c7ba7fdf0d54d4df44d6bc
b94e32
b94e32
diff --git a/gdb/testsuite/gdb.cp/namespace-nested-imports.cc b/gdb/testsuite/gdb.cp/namespace-nested-imports.cc
b94e32
new file mode 100644
b94e32
--- /dev/null
b94e32
+++ b/gdb/testsuite/gdb.cp/namespace-nested-imports.cc
b94e32
@@ -0,0 +1,36 @@
b94e32
+namespace A
b94e32
+{
b94e32
+  namespace B
b94e32
+  {
b94e32
+    int ab = 11;
b94e32
+  }
b94e32
+}
b94e32
+
b94e32
+namespace C
b94e32
+{
b94e32
+  namespace D
b94e32
+  {
b94e32
+    using namespace A::B;
b94e32
+
b94e32
+    int
b94e32
+    second()
b94e32
+    {
b94e32
+      ab;
b94e32
+      return 0;
b94e32
+    }
b94e32
+  }
b94e32
+
b94e32
+  int
b94e32
+  first()
b94e32
+  {
b94e32
+    //ab;
b94e32
+    return D::second();
b94e32
+  }
b94e32
+}
b94e32
+
b94e32
+int
b94e32
+main()
b94e32
+{
b94e32
+  //ab;
b94e32
+  return C::first();
b94e32
+}
b94e32
diff --git a/gdb/testsuite/gdb.cp/namespace-nested-imports.exp b/gdb/testsuite/gdb.cp/namespace-nested-imports.exp
b94e32
new file mode 100644
b94e32
--- /dev/null
b94e32
+++ b/gdb/testsuite/gdb.cp/namespace-nested-imports.exp
b94e32
@@ -0,0 +1,50 @@
b94e32
+# Copyright 2008 Free Software Foundation, Inc.
b94e32
+
b94e32
+# This program is free software; you can redistribute it and/or modify
b94e32
+# it under the terms of the GNU General Public License as published by
b94e32
+# the Free Software Foundation; either version 3 of the License, or
b94e32
+# (at your option) any later version.
b94e32
+#
b94e32
+# This program is distributed in the hope that it will be useful,
b94e32
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
b94e32
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b94e32
+# GNU General Public License for more details.
b94e32
+#
b94e32
+# You should have received a copy of the GNU General Public License
b94e32
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
b94e32
+
b94e32
+set testfile namespace-nested-imports
b94e32
+set srcfile ${testfile}.cc
b94e32
+set binfile [standard_output_file ${testfile}]
b94e32
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
b94e32
+    untested "Couldn't compile test program"
b94e32
+    return -1
b94e32
+}
b94e32
+
b94e32
+# Get things started.
b94e32
+
b94e32
+gdb_exit
b94e32
+gdb_start
b94e32
+gdb_reinitialize_dir $srcdir/$subdir
b94e32
+gdb_load ${binfile}
b94e32
+
b94e32
+############################################
b94e32
+if ![runto_main] then {
b94e32
+    perror "couldn't run to breakpoint main"
b94e32
+    continue
b94e32
+}
b94e32
+
b94e32
+gdb_test "print ab" "No symbol .* in current context."
b94e32
+
b94e32
+############################################
b94e32
+gdb_breakpoint C::first
b94e32
+gdb_continue_to_breakpoint "C::first"
b94e32
+
b94e32
+gdb_test "print ab" "No symbol .* in current context."
b94e32
+gdb_test "print C::D::ab" "= 11"
b94e32
+
b94e32
+############################################
b94e32
+gdb_breakpoint C::D::second
b94e32
+gdb_continue_to_breakpoint "C::D::second"
b94e32
+
b94e32
+gdb_test "print ab" "= 11"
b94e32
diff --git a/gdb/testsuite/gdb.cp/namespace-no-imports.cc b/gdb/testsuite/gdb.cp/namespace-no-imports.cc
b94e32
new file mode 100644
b94e32
--- /dev/null
b94e32
+++ b/gdb/testsuite/gdb.cp/namespace-no-imports.cc
b94e32
@@ -0,0 +1,37 @@
b94e32
+
b94e32
+namespace A
b94e32
+{
b94e32
+  int _a = 11;
b94e32
+
b94e32
+  namespace B{
b94e32
+
b94e32
+    int ab = 22;
b94e32
+
b94e32
+    namespace C{
b94e32
+
b94e32
+      int abc = 33;
b94e32
+
b94e32
+      int second(){
b94e32
+        return 0;
b94e32
+      }
b94e32
+
b94e32
+    }
b94e32
+
b94e32
+    int first(){
b94e32
+      _a;
b94e32
+      ab;
b94e32
+      C::abc;
b94e32
+      return C::second();
b94e32
+    }
b94e32
+  }
b94e32
+}
b94e32
+
b94e32
+
b94e32
+int
b94e32
+main()
b94e32
+{
b94e32
+  A::_a;
b94e32
+  A::B::ab;
b94e32
+  A::B::C::abc;
b94e32
+  return A::B::first();
b94e32
+}
b94e32
diff --git a/gdb/testsuite/gdb.cp/namespace-no-imports.exp b/gdb/testsuite/gdb.cp/namespace-no-imports.exp
b94e32
new file mode 100644
b94e32
--- /dev/null
b94e32
+++ b/gdb/testsuite/gdb.cp/namespace-no-imports.exp
b94e32
@@ -0,0 +1,69 @@
b94e32
+# Copyright 2008 Free Software Foundation, Inc.
b94e32
+
b94e32
+# This program is free software; you can redistribute it and/or modify
b94e32
+# it under the terms of the GNU General Public License as published by
b94e32
+# the Free Software Foundation; either version 3 of the License, or
b94e32
+# (at your option) any later version.
b94e32
+#
b94e32
+# This program is distributed in the hope that it will be useful,
b94e32
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
b94e32
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b94e32
+# GNU General Public License for more details.
b94e32
+#
b94e32
+# You should have received a copy of the GNU General Public License
b94e32
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
b94e32
+
b94e32
+set testfile namespace-no-imports
b94e32
+set srcfile ${testfile}.cc
b94e32
+set binfile [standard_output_file ${testfile}]
b94e32
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
b94e32
+    untested "Couldn't compile test program"
b94e32
+    return -1
b94e32
+}
b94e32
+
b94e32
+# Get things started.
b94e32
+
b94e32
+gdb_exit
b94e32
+gdb_start
b94e32
+gdb_reinitialize_dir $srcdir/$subdir
b94e32
+gdb_load ${binfile}
b94e32
+
b94e32
+############################################
b94e32
+if ![runto_main] then {
b94e32
+    perror "couldn't run to breakpoint main"
b94e32
+    continue
b94e32
+}
b94e32
+
b94e32
+gdb_test "print A::_a" "= 11"
b94e32
+gdb_test "print A::B::ab" "= 22"
b94e32
+gdb_test "print A::B::C::abc" "= 33"
b94e32
+
b94e32
+gdb_test "print _a" "No symbol .* in current context."
b94e32
+gdb_test "print ab" "No symbol .* in current context."
b94e32
+gdb_test "print abc" "No symbol .* in current context."
b94e32
+
b94e32
+############################################
b94e32
+gdb_breakpoint A::B::first
b94e32
+gdb_continue_to_breakpoint "A::B::first"
b94e32
+
b94e32
+gdb_test "print A::_a" "= 11"
b94e32
+gdb_test "print A::B::ab" "= 22"
b94e32
+gdb_test "print A::B::C::abc" "= 33"
b94e32
+
b94e32
+gdb_test "print _a" "= 11"
b94e32
+gdb_test "print ab" "= 22"
b94e32
+gdb_test "print C::abc" "= 33"
b94e32
+
b94e32
+gdb_test "print abc" "No symbol .* in current context."
b94e32
+
b94e32
+############################################
b94e32
+gdb_breakpoint A::B::C::second
b94e32
+gdb_continue_to_breakpoint "A::B::C::second"
b94e32
+
b94e32
+gdb_test "print A::_a" "= 11"
b94e32
+gdb_test "print A::B::ab" "= 22"
b94e32
+gdb_test "print A::B::C::abc" "= 33"
b94e32
+
b94e32
+gdb_test "print _a" "= 11"
b94e32
+gdb_test "print ab" "= 22"
b94e32
+gdb_test "print abc" "= 33"