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

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