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

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