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

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