Check for warning flags without no- prefix
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / static-method.exp
CommitLineData
fd336a18
KS
1# Copyright 2011 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
20# A helper proc which sets a breakpoint at FUNC and attempts to
21# run to the breakpoint.
22proc test_breakpoint {func result} {
23 set DEC {[0-9]}
24
25 # Return to the top of the test function every time.
26 delete_breakpoints
27 if {![gdb_breakpoint test_function]} {
28 fail "set test_function breakpoint for $func"
29 } elseif {[gdb_test "continue" \
30 "Continuing.\r\n\r\nBreakpoint $DEC+,.*test_function.*" \
31 ""] != 0} {
32 fail "continue to test_function for $func"
33 } else {
34 gdb_breakpoint "$func"
35 gdb_test "continue" \
36 "Continuing.\r\n\r\nBreakpoint $DEC+,.*$result.*" \
37 "continue to $func"
38 }
39}
40
41if {[skip_cplus_tests]} { continue }
42
43# Tests for c++/12750
44set testfile "static-method"
45set srcfile $testfile.cc
46
47if {[prepare_for_testing $testfile $testfile $srcfile {c++ debug}]} {
48 return -1
49}
50
0a00efc3
JK
51# The GDB workaround for GCC PR debug/45682 does not apply as it requires
52# DW_AT_linkage_name of methods. The whole class A is in anonymous namespace,
53# therefore not accessible outside of the CU (compilation unit) and therefore
54# GCC does not produce DW_AT_linkage_name for such methods.
55
56set have_gcc_45682_fixed 1
57set test "info addr A::func()"
58gdb_test_multiple $test $test {
59 -re "No symbol \"A::func\\(\\)\" in current context\\.\r\n$gdb_prompt $" {
60 pass $test
61 }
62 -re "Symbol \"A::func\\(\\)\" is a function at address .*\r\n$gdb_prompt $" {
63 kfail gcc/45682 $test
64 set have_gcc_45682_fixed 0
65 }
66}
67
fd336a18
KS
68if {![runto_main]} {
69 perror "couldn't run to breakpoint"
70 continue
71}
72
73set ans {(anonymous namespace)}
74set methods {}
75lappend methods "xxx::${ans}::func"
76lappend methods "xxx::${ans}::A::func"
77
78gdb_test_no_output "set listsize 1" ""
79
80foreach test $methods {
81 # The result we expect is the source code name of the symbol,
82 # i.e., without "(anonymous namespace)".
83 regsub -all [string_to_regexp "${ans}::"] $test "" expected
84 set result ".*// [string_to_regexp $expected]"
85
86 # Test whether the function/method can be "list"ed
87 # with the filename pre-pended.
0a00efc3
JK
88 if {[string compare $test "xxx::${ans}::A::func"] == 0
89 && !$have_gcc_45682_fixed} {
90 setup_kfail gcc/45682 "*-*-*"
91 }
fd336a18 92 gdb_test "list ${srcfile}:$test" $result
0a00efc3
JK
93 if {[string compare $test "xxx::${ans}::A::func"] == 0
94 && !$have_gcc_45682_fixed} {
95 setup_kfail gcc/45682 "*-*-*"
96 }
fd336a18 97 gdb_test "list '${srcfile}:$test'" $result
0a00efc3
JK
98 if {[string compare $test "xxx::${ans}::A::func"] == 0
99 && !$have_gcc_45682_fixed} {
100 setup_kfail gcc/45682 "*-*-*"
101 }
f65cf84c 102 gdb_test "list '${srcfile}':'$test'" $result
0a00efc3
JK
103 if {[string compare $test "xxx::${ans}::A::func"] == 0
104 && !$have_gcc_45682_fixed} {
105 setup_kfail gcc/45682 "*-*-*"
106 }
fd336a18
KS
107 gdb_test "list ${srcfile}:'$test'" $result
108
109 # Test setting and hitting a breakoint at the function/method.
110 test_breakpoint $test $expected
111 test_breakpoint "'$test'" $expected
112}
113
114gdb_exit
115return 0
This page took 0.083847 seconds and 4 git commands to generate.