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

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