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

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