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

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