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