From: Keith Seitz Date: Tue, 31 May 2011 21:54:49 +0000 (+0000) Subject: PR symtab/12704 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fa8b9902af001abd6644344997f323fbe3fe2c59;p=binutils-gdb.git PR symtab/12704 * gdb.cp/anon-ns.cc: New file. * gdb.cp/anon-ns.exp: New file. --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 3d89273725a..2e5e4cb762f 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2010-05-31 Keith Seitz + + PR symtab/12704 + * gdb.cp/anon-ns.cc: New file. + * gdb.cp/anon-ns.exp: New file. + 2011-05-31 Pedro Alves * 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 00000000000..949754de1d9 --- /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 . + + Contributed by Red Hat, originally written by Keith Seitz. */ + +#include + +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 (NULL)); + one::doit (); + A::two d, e (3), f (static_cast (NULL)); + A::two::doit (); + A::three g, h (3), i (static_cast (NULL)); + A::three::doit (); + doit1 (); + doit1 (3); + doit1 (static_cast (NULL)); + A::doit2 (); + A::doit2 (3); + A::doit2 (static_cast (NULL)); + A::doit3 (); + A::doit3 (3); + A::doit3 (static_cast (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 00000000000..07d804c00b8 --- /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 . + +# 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