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

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