1# Copyright 2011-2023 Free Software Foundation, Inc.
2#
3# Contributed by Red Hat, originally written by Keith Seitz.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18# This file is part of the gdb testsuite.
19
20if {[skip_cplus_tests]} { return }
21
22standard_testfile .cc anon-ns2.cc
23
24if {[prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2" {c++ debug}]} {
25    return -1
26}
27
28if {![runto_main]} {
29    return
30}
31
32set ans {(anonymous namespace)}
33set types {"void" "int" "char *"}
34set methods {}
35foreach t $types {
36    lappend methods "${ans}::doit1($t)"
37    lappend methods "${ans}::one::one($t)"
38    lappend methods "${ans}::A::doit2($t)"
39    lappend methods "${ans}::A::two::two($t)"
40    lappend methods "${ans}::A::${ans}::${ans}::doit3($t)"
41    lappend methods "${ans}::A::${ans}::${ans}::three::three($t)"
42}
43
44lappend methods "${ans}::one::doit(void)"
45lappend methods "${ans}::A::two::doit(void)"
46lappend methods "${ans}::A::${ans}::${ans}::three::doit(void)"
47
48gdb_test_no_output "set listsize 1" ""
49
50foreach test $methods {
51    # The result we expect is the source code name of the symbol,
52    # i.e., without "(anonymous namespace)".
53    regsub -all [string_to_regexp "${ans}::"] $test "" expected
54    set result ".*// [string_to_regexp $expected]"
55
56    gdb_test "list $test" $result
57    gdb_test "list '$test'" $result
58    if {[gdb_breakpoint $test]} {
59	pass "break $test"
60    }
61    if {[gdb_breakpoint '$test']} {
62	pass "break '$test'"
63    }
64}
65
66# PR c++/17976
67gdb_test "ptype '(anonymous namespace)'" \
68    "type = namespace \\\(anonymous namespace\\\)"
69
70gdb_exit
71return 0
72