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

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