]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.cp/meth-typedefs.exp
Fix more cases of improper test names
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.cp / meth-typedefs.exp
CommitLineData
618f726f 1# Copyright 2011-2016 Free Software Foundation, Inc.
59cde39c
KS
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
20proc add {var name params expected {kind {func}}} {
21 upvar $var result
22
23 if {[string compare $kind "template"] == 0} {
24 set method_name "${name}<$expected>"
25 } else {
26 set method_name "$name"
27 }
28
29 set expect ".*// ${method_name}\\($expected\\)"
30 lappend result [list "${method_name}($params)" $expect]
31}
32
33if {[skip_cplus_tests]} { continue }
34
35# Tests for c++/12266 et al
f5f3a911 36standard_testfile .cc
59cde39c 37
5b362f04 38if {[prepare_for_testing "failed to prepare" $testfile $srcfile {c++ debug}]} {
59cde39c
KS
39 return -1
40}
41
42if {![runto_main]} {
43 perror "couldn't run to breakpoint"
44 continue
45}
46
47array set typedefs {
48 "my_other_type" {"my_other_type" "my_type" "const char* const*"}
49 "my_other_type_2" {"my_other_type_2" "my_type_2" "int"}
50 "CORE_ADDR" { "CORE_ADDR" "unsigned long" }
51 "_BAR_" { "_BAR_" "a::b::BAR" "a::b::c::d::bar" }
52 "aenum" { "aenum" "anon_enum" }
53 "astruct" { "astruct" "anon_struct" }
54 "aunion" { "aunion" "anon_union" }
55}
56
57set methods {}
58
59# Add the simple, one-parameter methods
60foreach meth {A::FOO::test A::FOO::foo} {
61 foreach type {my_other_type my_other_type_2} {
62 foreach t $typedefs($type) {
63 add methods $meth $t $type
64 }
65 }
66}
67
68# Add two-parameter methods
69foreach meth {A::FOO::test A::FOO::foo} {
70 set type "my_other_type_2, const my_other_type"
71 foreach t1 $typedefs(my_other_type_2) {
72 foreach t2 $typedefs(my_other_type) {
73 add methods $meth "$t1, const $t2" $type
74 add methods $meth "$t1, $t2" $type
75 }
76 }
77}
78
79# Add three-parameter methods/functions
80foreach meth {A::FOO::test A::FOO::foo B::test test} {
81 set type "aenum, astruct const&, aunion const\\*\\*\\*"
82 foreach t1 $typedefs(aenum) {
83 foreach t2 $typedefs(astruct) {
84 foreach t3 $typedefs(aunion) {
85 add methods $meth "$t1, $t2 const&, $t3 const***" $type
86 }
87 }
88 }
89}
90
91# Add the array-of-function pointer methods
92set type "fptr1\\*"
93foreach meth {A::FOO::test A::FOO::foo} {
94 add methods $meth "fptr1*" $type
95 foreach t $typedefs(my_other_type) {
96 add methods $meth "void (**) ($t)" $type
97 }
98}
99
100# Add the function pointer methods
101set type "fptr3"
102foreach meth {A::FOO::test A::FOO::foo} {
103 add methods $meth "fptr3" $type
104
105 foreach t1 $typedefs(my_other_type) {
106 add methods $meth "void (*)(fptr2, $t1)" $type
107 foreach t2 $typedefs(my_other_type_2) {
108 add methods $meth "void (*)(void (*)(fptr1, $t2), $t1)" $type
109 foreach t3 $typedefs(my_other_type) {
110 add methods $meth \
111 "void (*)(void (*)(void (*) ($t3), $t2), $t1)" $type
112 }
113 }
114 }
115}
116
117set type1 "my_other_type"
118set type2 "my_other_type, my_other_type_2"
119foreach meth {"test" "B::test"} {
120 foreach t1 $typedefs(my_other_type) {
121 add methods $meth $t1 $type1
122 foreach t2 $typedefs(my_other_type_2) {
123 add methods $meth "$t1, $t2" $type2 template
124 }
125 }
126}
127
128# Miscellaneous tests
129set type {CORE_ADDR \(\*\) \[10\]}
130foreach meth {A::FOO::foo A::FOO::test} {
131 foreach t $typedefs(CORE_ADDR) {
132 add methods $meth "$t (*) \[10\]" $type
133 }
134}
135
136foreach t $typedefs(_BAR_) {
137 add methods "test" "$t&" {_BAR_&}
138}
139
140gdb_test_no_output "set listsize 1" ""
141
142# Finally, for each method in the list METHODS, check whether
143# the user can "list" it and "break" on it (both quoted and unquoted).
144foreach test $methods {
145 set func [lindex $test 0]
146 set result [lindex $test 1]
147
148 gdb_test "list $func" $result
149 gdb_test "list '$func'" $result
150 if {[gdb_breakpoint $func]} {
151 pass "break $func"
152 }
153 if {[gdb_breakpoint '$func']} {
154 pass "break '$func'"
155 }
156}
157
158gdb_exit
159return 0