aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2011-05-31 21:54:49 +0000
committerKeith Seitz <keiths@redhat.com>2011-05-31 21:54:49 +0000
commitfa8b9902af001abd6644344997f323fbe3fe2c59 (patch)
treec8dd823de9587e05c7c6d7426e51b6c5834f42b9 /gdb/testsuite
parent2b1dbab03d9b512f15900cb274f69214bd88d3bc (diff)
downloadgdb-fa8b9902af001abd6644344997f323fbe3fe2c59.zip
gdb-fa8b9902af001abd6644344997f323fbe3fe2c59.tar.gz
gdb-fa8b9902af001abd6644344997f323fbe3fe2c59.tar.bz2
PR symtab/12704
* gdb.cp/anon-ns.cc: New file. * gdb.cp/anon-ns.exp: New file.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.cp/anon-ns.cc92
-rw-r--r--gdb/testsuite/gdb.cp/anon-ns.exp70
3 files changed, 168 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 3d89273..2e5e4cb 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2010-05-31 Keith Seitz <keiths@redhat.com>
+
+ PR symtab/12704
+ * gdb.cp/anon-ns.cc: New file.
+ * gdb.cp/anon-ns.exp: New file.
+
2011-05-31 Pedro Alves <pedro@codesourcery.com>
* gdb.arch/i386-dr3-watch.c: New file.
diff --git a/gdb/testsuite/gdb.cp/anon-ns.cc b/gdb/testsuite/gdb.cp/anon-ns.cc
new file mode 100644
index 0000000..949754d
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/anon-ns.cc
@@ -0,0 +1,92 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2011 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ Contributed by Red Hat, originally written by Keith Seitz. */
+
+#include <stdlib.h>
+
+namespace
+{
+ void doit1 (void) { } // doit1(void)
+ void doit1 (int a) { } // doit1(int)
+ void doit1 (char *a) { } // doit1(char *)
+
+ class one
+ {
+ public:
+ one (void) { } // one::one(void)
+ one (int a) { } // one::one(int)
+ one (char *a) { } // one::one(char *)
+ static void doit (void) { } // one::doit(void)
+ };
+
+ namespace A
+ {
+ void doit2 (void) { } // A::doit2(void)
+ void doit2 (int a) { } // A::doit2(int)
+ void doit2 (char *a) { } // A::doit2(char *)
+
+ class two
+ {
+ public:
+ two (void) { } // A::two::two(void)
+ two (int a) { } // A::two::two(int)
+ two (char *a) { } // A::two::two(char *)
+ static void doit (void) { } // A::two::doit(void)
+ };
+
+ namespace
+ {
+ namespace
+ {
+ void doit3 (void) { } // A::doit3(void)
+ void doit3 (int a) { } // A::doit3(int)
+ void doit3 (char *a) { } // A::doit3(char *)
+
+ class three
+ {
+ public:
+ three (void) { } // A::three::three(void)
+ three (int a) { } // A::three::three(int)
+ three (char *a) { } // A::three::three(char *)
+ static void doit (void) { } // A::three::doit(void)
+ };
+ }
+ }
+ }
+}
+
+int
+main (void)
+{
+ one a, b (3), c (static_cast<char *> (NULL));
+ one::doit ();
+ A::two d, e (3), f (static_cast<char *> (NULL));
+ A::two::doit ();
+ A::three g, h (3), i (static_cast<char *> (NULL));
+ A::three::doit ();
+ doit1 ();
+ doit1 (3);
+ doit1 (static_cast<char *> (NULL));
+ A::doit2 ();
+ A::doit2 (3);
+ A::doit2 (static_cast<char *> (NULL));
+ A::doit3 ();
+ A::doit3 (3);
+ A::doit3 (static_cast<char *> (NULL));
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.cp/anon-ns.exp b/gdb/testsuite/gdb.cp/anon-ns.exp
new file mode 100644
index 0000000..07d804c
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/anon-ns.exp
@@ -0,0 +1,70 @@
+# Copyright 2011 Free Software Foundation, Inc.
+#
+# Contributed by Red Hat, originally written by Keith Seitz.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the gdb testsuite.
+
+if {[skip_cplus_tests]} { continue }
+
+# Tests for c++/12750/12704
+set testfile "anon-ns"
+set srcfile $testfile.cc
+
+if {[prepare_for_testing $testfile $testfile $srcfile {c++ debug}]} {
+ return -1
+}
+
+if {![runto_main]} {
+ perror "couldn't run to breakpoint"
+ continue
+}
+
+set ans {(anonymous namespace)}
+set types {"void" "int" "char *"}
+set methods {}
+foreach t $types {
+ lappend methods "${ans}::doit1($t)"
+ lappend methods "${ans}::one::one($t)"
+ lappend methods "${ans}::A::doit2($t)"
+ lappend methods "${ans}::A::two::two($t)"
+ lappend methods "${ans}::A::${ans}::${ans}::doit3($t)"
+ lappend methods "${ans}::A::${ans}::${ans}::three::three($t)"
+}
+
+lappend methods "${ans}::one::doit(void)"
+lappend methods "${ans}::A::two::doit(void)"
+lappend methods "${ans}::A::${ans}::${ans}::three::doit(void)"
+
+gdb_test_no_output "set listsize 1" ""
+
+foreach test $methods {
+ # The result we expect is the source code name of the symbol,
+ # i.e., without "(anonymous namespace)".
+ regsub -all [string_to_regexp "${ans}::"] $test "" expected
+ set result ".*// [string_to_regexp $expected]"
+
+ gdb_test "list $test" $result
+ gdb_test "list '$test'" $result
+ if {[gdb_breakpoint $test]} {
+ pass "break $test"
+ }
+ if {[gdb_breakpoint '$test']} {
+ pass "break '$test'"
+ }
+}
+
+gdb_exit
+return 0