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

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