* gdb.dwarf2/implptr-optimized-out.S: DIE offset for
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / templates.exp
CommitLineData
0b302171
JB
1# Copyright 1992, 1994-1997, 1999-2000, 2002-2004, 2007-2012 Free
2# Software Foundation, Inc.
c906108c
SS
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
e22f8b7c 6# the Free Software Foundation; either version 3 of the License, or
c906108c 7# (at your option) any later version.
e22f8b7c 8#
c906108c
SS
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
e22f8b7c 13#
c906108c 14# You should have received a copy of the GNU General Public License
e22f8b7c 15# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c 16
c906108c
SS
17# This file was written by Fred Fish. (fnf@cygnus.com)
18
19set ws "\[\r\n\t \]+"
20
d4f3574e
SS
21if { [skip_cplus_tests] } { continue }
22
f5f3a911 23standard_testfile .cc
c906108c
SS
24
25# Create and source the file that provides information about the compiler
26# used to compile the test case.
4c93b1db 27if [get_compiler_info "c++"] {
c906108c
SS
28 return -1
29}
c906108c 30
f5f3a911
TT
31if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
32 return -1
c906108c
SS
33}
34
c906108c
SS
35#
36# Test printing of the types of templates.
37#
38
39proc test_ptype_of_templates {} {
40 global gdb_prompt
41 global ws
42
bd69fc68 43 gdb_test_multiple "ptype/r T5<int>" "ptype T5<int>" {
1bc05c3a 44 -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5<int> & operator=\\(T5<int> const ?&\\);${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" {
3b7962f9 45 xfail "ptype T5<int> -- new without size_t"
c906108c 46 }
3b0cb202 47 -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}T5<int> & operator=\\(T5<int> const ?&\\);${ws}\}\r\n$gdb_prompt $" {
3b7962f9 48 xfail "ptype T5<int> -- new without size_t"
3b0cb202 49 }
f8d3bf8f 50 -re "type = class T5<int> \\{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}${ws}T5 \\(int\\);${ws}T5 \\(const class T5<int> &\\);${ws}void ~T5 \\(int\\);${ws}static void \\* new \\(unsigned int\\);${ws}static void delete \\(void ?\\*\\);${ws}int value \\((void|)\\);${ws}\\}${ws}$gdb_prompt $" {
3b7962f9 51 xfail "ptype T5<int> -- new with unsigned int"
f8d3bf8f
MS
52 }
53 -re "type = class T5<int> \\{.*public:.*static int X;.*int x;.*int val;.*T5 \\(int\\);.*T5 \\(const class T5<int> &\\);.*void ~T5 \\(int\\);.*static void \\* new \\(unsigned long\\);.*static void delete \\(void ?\\*\\);.*int value \\((void|)\\);.*\\}\r\n$gdb_prompt $" {
3b7962f9 54 xfail "ptype T5<int> -- new with unsigned long"
f8d3bf8f 55 }
1bc05c3a 56 -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;((${ws}T5<int> & operator=\\(T5<int> const ?&\\);)|(${ws}T5\\(int\\);)|(${ws}T5\\((T5<int> const|const T5<int>) ?&\\);)|(${ws}~T5\\((void|)\\);)|(${ws}static void \\* operator new\\(unsigned( int| long)?\\);)|(${ws}static void operator delete\\(void ?\\*\\);)|(${ws}int value\\((void|)\\);))*${ws}\}\r\n$gdb_prompt $" {
3b7962f9 57 xfail "ptype T5<int> (obsolescent gcc or gdb)"
c906108c 58 }
3b7962f9 59 -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}void T5\\(int\\);${ws}void T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\(int\\);${ws}static void \\* operator new\\((size_t|unsigned( int| long|))\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" {
5330f2db
DC
60 # This also triggers gdb/1113...
61 kfail "gdb/1111" "ptype T5<int>"
3b7962f9 62 # Add here a PASS case when PR gdb/1111 gets fixed.
5330f2db 63 }
c906108c
SS
64 }
65
bd69fc68 66 gdb_test_multiple "ptype/r t5i" "ptype t5i" {
f8d3bf8f 67 -re "type = class T5<int> \\{${ws}public:${ws}static int X;${ws}int x;${ws}int val;\r\n${ws}T5\\(int\\);${ws}T5\\(T5<int> const ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\\}\r\n$gdb_prompt $" {
3b7962f9 68 xfail "ptype T5<int> -- with several fixes from 4.17 -- without size_t"
f8d3bf8f
MS
69 }
70 -re "type = class T5<int> \\{${ws}public:${ws}static int X;${ws}int x;${ws}int val;\r\n${ws}T5 \\(int\\);${ws}T5 \\(const class T5<int> &\\);${ws}void ~T5 \\(int\\);${ws}static void \\* new \\(unsigned int\\);${ws}static void delete \\(void ?\\*\\);${ws}int value \\((void|)\\);${ws}\\}\r\n$gdb_prompt $" {
3b7962f9 71 xfail "ptype t5i<int> -- new with unsigned int -- without size_t"
f8d3bf8f
MS
72 }
73 -re "type = class T5<int> \\{${ws}public:${ws}static int X;${ws}int x;${ws}int val;\r\n${ws}T5 \\(int\\);${ws}T5 \\(const class T5<int> &\\);${ws}void ~T5 \\(int\\);${ws}static void \\* new \\(unsigned long\\);${ws}static void delete \\(void ?\\*\\);${ws}int value \\((void|)\\);${ws}\\}\r\n$gdb_prompt $" {
3b7962f9 74 xfail "ptype t5i<int> -- new with unsigned long -- without size_t"
f8d3bf8f 75 }
eef747c0 76 -re "type = class T5<int> \{.*public:.*static int X;.*int x;.*int val;.*.*T5 \\(int\\);.*.*void ~T5 \\(int\\).*.*.*int value \\((void|)\\);.*\}.*$gdb_prompt $" {
3b7962f9 77 xfail "ptype t5i -- without size_t"
a0b3c4fd 78 }
1bc05c3a 79 -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5<int> & operator=\\(T5<int> const ?&\\);${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" {
3b7962f9 80 xfail "ptype t5i -- without size_t"
c906108c 81 }
3b0cb202 82 -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}T5<int> & operator=\\(T5<int> const ?&\\);${ws}\}\r\n$gdb_prompt $" {
3b7962f9 83 xfail "ptype t5i -- without size_t"
3b0cb202 84 }
3b2a7ae5 85 -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;((${ws}T5<int> & operator=\\(T5<int> const ?&\\);)|(${ws}T5\\(int\\);)|(${ws}T5\\(T5<int> const ?&\\);)|(${ws}~T5\\((void|)\\);)|(${ws}static void \\* operator new\\(unsigned( int| long)?\\);)|(${ws}static void operator delete\\(void ?\\*\\);)|(${ws}int value\\((void|)\\);))*${ws}\}\r\n$gdb_prompt $" {
3b7962f9 86 xfail "ptype t5i (obsolescent gcc or gdb) -- without size_t"
c906108c 87 }
3b7962f9 88 -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}void T5\\(int\\);${ws}void T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\(int\\);${ws}static void \\* operator new\\((size_t|unsigned( int| long|))\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" {
5330f2db
DC
89 # This also triggers gdb/1113...
90 kfail "gdb/1111" "ptype T5<int>"
3b7962f9 91 # Add here a PASS case when PR gdb/1111 gets fixed.
5330f2db 92 }
c906108c
SS
93 }
94}
95
96#
97# Test breakpoint setting on template methods.
98#
99
100proc test_template_breakpoints {} {
101 global gdb_prompt
102 global testfile
103 global srcdir
a0b3c4fd 104 global hp_aCC_compiler
c906108c 105
b598bfda 106 gdb_test_multiple "break T5<int>::T5" "constructor breakpoint" {
f8eba3c6 107 -re "0. cancel.*\[\r\n\]*.1. all.*\[\r\n\]*.2.*templates.cc:T5<int>::T5\\((T5<int> const|const T5<int>) ?&\\)\[\r\n\]*.3.*templates.cc:T5<int>::T5\\(int\\)\[\r\n\]*> $" {
c906108c 108 gdb_test "0" \
a9e2e984 109 "canceled" \
c906108c
SS
110 "constructor breakpoint"
111 }
5330f2db
DC
112 -re "0. cancel.*\[\r\n\]*.1. all.*\[\r\n\]*.2. T5 at .*\[\r\n\]*.3. T5 at .*\[\r\n\]*> $" {
113 setup_kfail "gdb/1062" "*-*-*"
114 gdb_test "0" \
115 "nonsense intended to insure that this test fails" \
116 "constructor breakpoint"
117 }
760f6330
MS
118 -re ".*\n> $" {
119 gdb_test "0" \
120 "nonsense intended to insure that this test fails" \
121 "constructor breakpoint (bad menu choices)"
122 }
c906108c
SS
123 }
124
a0b3c4fd
JM
125# See CLLbs14792
126 if {$hp_aCC_compiler} {setup_xfail hppa*-*-* CLLbs14792}
5330f2db
DC
127
128 gdb_test_multiple "break T5<int>::~T5" "destructor_breakpoint" {
129 -re "Breakpoint.*at.* file .*${testfile}.cc, line.*$gdb_prompt $"
130 {
131 pass "destructor breakpoint"
132 }
133 -re "the class `T5<int>' does not have destructor defined\r\nHint: try 'T5<int>::~T5<TAB> or 'T5<int>::~T5<ESC-\\?>\r\n\\(Note leading single quote.\\)\r\n$gdb_prompt $"
134 {
135 kfail "gdb/1112" "destructor breakpoint"
136 }
137 }
c906108c
SS
138
139 gdb_test "break T5<int>::value" \
140 "Breakpoint.*at.* file .*${testfile}.cc, line.*" \
141 "value method breakpoint"
142
945a118d
JG
143 set bp_location [gdb_get_line_number \
144 "set breakpoint on a line with no real code"]
f8eba3c6
TT
145
146 gdb_test_multiple "break ${testfile}.cc:${bp_location}" \
147 "breakpoint on a line with no real code" {
148 -re "0. cancel.*\[\r\n\]*.1. all.*\[\r\n\]*.2.*templates.cc:GetMax<int>\\(int, int\\)\[\r\n\]*.3.*templates.cc:GetMax<long>\\(long, long\\)\[\r\n\]*> $" {
149 gdb_test "0" \
150 "canceled" \
151 "breakpoint on a line with no real code"
152 }
153 -re "0. cancel.*\[\r\n\]*.1. all.*\[\r\n\]*.2.*\[\r\n\]*.3.*\[\r\n\]*> $" {
154 gdb_test "0" \
155 "nonsense intended to insure that this test fails" \
156 "breakpoint on a line with no real code"
157 }
158 -re ".*\n> $" {
159 gdb_test "0" \
160 "nonsense intended to insure that this test fails" \
161 "breakpoint on a line with no real code"
162 }
163 }
164
c906108c
SS
165 delete_breakpoints
166}
167
168#
169# Test calling of template methods.
170#
171
172proc test_template_calls {} {
173 global gdb_prompt
a0b3c4fd 174 global hp_aCC_compiler
c906108c
SS
175
176 if [target_info exists gdb,cannot_call_functions] {
177 setup_xfail "*-*-*" 2416
178 fail "This target can not call functions"
179 return
180 }
181
a0b3c4fd 182 if {!$hp_aCC_compiler} {setup_xfail hppa*-*-*}
f8d3bf8f
MS
183 gdb_test_multiple "print t5i.value()" "print t5i.value()" {
184 -re ".* = 2\[\r\n\]*$gdb_prompt $" {
185 pass "print t5i.value()"
186 }
c906108c
SS
187 -re "Cannot invoke functions on this machine.*$gdb_prompt $" {
188 fail "print t5i.value()"
189 }
a0b3c4fd
JM
190 -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" {
191 setup_xfail hppa*-*-* CLLbs16899
192 xfail "print t5i.value"
193 }
c906108c
SS
194 }
195}
196
3fe8f3b3 197proc test_template_typedef {} {
ae1a303e 198 global gdb_prompt
3fe8f3b3
KS
199
200 gdb_test "print intBazOne::baz" ".*baz\\(int, int\\)>" \
201 "print method of template typedef"
202
ae1a303e
JK
203 set test "print destructor of template typedef"
204 gdb_test_multiple "print intBazOne::~Baz" $test {
205 -re "~Baz(\\(\\))?>\r\n$gdb_prompt $" {
206 pass $test
207 }
208 -re "There is no field named ~Baz\r\n$gdb_prompt $" {
209 set test2 "verify GCC PR debug/51668"
210 gdb_test_multiple "whatis intBazOne" $test2 {
211 -re "type = Baz<int, \\(char\\)'\\\\001'>\r\n$gdb_prompt $" {
212 setup_xfail gcc/51668 "*-*-*"
213 xfail $test
214 pass $test2
215 }
216 -re "\r\n$gdb_prompt $" {
217 # Some unexpected response.
218 fail $test
219 fail $test2
220 }
221 }
222 }
223 }
3fe8f3b3 224}
c906108c 225
c767944b
DJ
226proc test_template_args {} {
227
228 set empty_re "Empty *<void *\\(FunctionArg *<int>\\)>"
bd69fc68
TT
229 gdb_test "ptype/r empty" \
230 "type = (struct|class) $empty_re {.*<no data fields>.*}" \
231 "ptype empty"
c767944b 232
bd69fc68
TT
233 gdb_test "ptype/r arg" \
234 "type = (struct|class) FunctionArg<int> {.*int method\\($empty_re \\&\\);.*}" \
235 "ptype arg"
c767944b
DJ
236}
237
c906108c 238proc do_tests {} {
eae06beb
JB
239 # Change multiple-symbols to "ask" in order to get the multiple-choice
240 # menu when breaking on overloaded methods.
a8d52276 241 gdb_test_no_output "set multiple-symbols ask"
eae06beb 242
40f235b7 243 runto_main
c906108c
SS
244
245 test_ptype_of_templates
246 test_template_breakpoints
3fe8f3b3 247 test_template_typedef
c767944b 248 test_template_args
c906108c
SS
249
250 if [ runto_main] {
251 test_template_calls
252 }
253}
254
255do_tests
256
a0b3c4fd
JM
257
258# More tests for different kinds of template parameters,
259# templates with partial specializations, nested templates, etc.
260# These have been tested only with HP aCC. They probably won't
261# work with other compilers because of differences in mangling
262# schemes.
263# Added by Satish Pai <pai@apollo.hp.com> 1997-09-25
e6d71bf3
DB
264# As of 2000-06-03, C++ support has been improved to the point that g++ can
265# pass all of theses, excluding what appears to be one that exposes a stabs bug. - djb
a0b3c4fd 266
e6d71bf3
DB
267# I don't know how HP could be passing these tests without this. They
268# weren't breakpointing past a point where the below expressions were
269# initialized in the actual source. - djb
270
f8d3bf8f
MS
271gdb_test "b 770" \
272 "Breakpoint .* at .*, line 770."
a0b3c4fd 273
f8d3bf8f
MS
274gdb_test "c" \
275 "Continuing.*Breakpoint .*" \
276 "continue to line 770"
277
278gdb_test "print fint" \
279 "\\$\[0-9\]* = \\{x = 0, t = 0\\}"
280
281gdb_test "print fvpchar" \
282 "\\$\[0-9\]* = \\{x = 0, t = 0x0\\}"
a0b3c4fd
JM
283
284# Template Foo<T>
285
dd14ab43
DC
286# Neither stabs nor DWARF-2 contains type information about templates
287# (as opposed to instantiations of templates), so in those
288# circumstances we expect GDB to not find a symbol. HP has a debug
289# format that contains more info, though, so it's also correct to
290# print out template info. (This affects several subsequent tests as
291# well.)
292
293# NOTE: carlton/2003-02-26: However, because of a bug in the way GDB
294# handles nested types, we don't get this right in the DWARF-2 case.
295
bd69fc68 296gdb_test_multiple "ptype/r Foo" "ptype Foo" {
f8d3bf8f
MS
297 -re "type = template <(class |)T> (class |)Foo \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Foo<volatile char \\*>\r\n\[ \t\]*(class |)Foo<char>\r\n\[ \t\]*(class |)Foo<int>\r\n$gdb_prompt $" {
298 pass "ptype Foo"
299 }
300 -re "type = template <(class |)T> (class |)Foo \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\n$gdb_prompt $" {
301 xfail "ptype Foo"
302 }
303 -re "type = class Foo<int> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int foo\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" {
304 # GCC 3.1, DWARF-2 output.
305 kfail "gdb/57" "ptype Foo"
306 }
307 -re "No symbol \"Foo\" in current context.\r\n$gdb_prompt $" {
308 # GCC 2.95.3, stabs+ output.
309 pass "ptype Foo"
310 }
a0b3c4fd 311}
f8d3bf8f 312
dd14ab43 313# -re "type = class Foo<int> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int foo(int, int);\r\n\\}\r\n$gdb_prompt $"
a0b3c4fd
JM
314
315# ptype Foo<int>
316
bd69fc68 317gdb_test_multiple "ptype/r fint" "ptype fint" {
f8d3bf8f
MS
318 -re "type = (class |)Foo<int> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int foo\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" {
319 pass "ptype fint"
320 }
321 -re "type = (class |)Foo<int> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int foo\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" {
322 pass "ptype fint"
323 }
a0b3c4fd
JM
324}
325
326# ptype Foo<char>
327
bd69fc68 328gdb_test_multiple "ptype/r fchar" "ptype fchar" {
f8d3bf8f
MS
329 -re "type = (class |)Foo<char> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*.*char foo\\(int, char\\);\r\n\\}\r\n$gdb_prompt $" {
330 pass "ptype fchar"
331 }
332 -re "type = (class |)Foo<char> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*char foo\\(int, char\\);.*\r\n\\}\r\n$gdb_prompt $" {
333 pass "ptype fchar"
334 }
a0b3c4fd
JM
335}
336
337# ptype Foo<volatile char *>
338
bd69fc68 339gdb_test_multiple "ptype/r fvpchar" "ptype fvpchar" {
f8d3bf8f
MS
340 -re "type = (class |)Foo<volatile char ?\\*> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*char.*\\*t;\r\n\r\n\[ \t\]*.*char \\* foo\\(int,.*char.*\\*\\);\r\n\\}\r\n$gdb_prompt $" {
341 pass "ptype fvpchar"
342 }
343 -re "type = (class |)Foo<volatile char ?\\*> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*char.*\\*t;\r\n\r\n\[ \t\]*.*char \\* foo\\(int,.*char.*\\*\\);.*\r\n\\}\r\n$gdb_prompt $" {
344 pass "ptype fvpchar"
345 }
346 -re "type = (class |)Foo<char volatile ?\\*> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*char.*\\*t;\r\n\r\n\[ \t\]*.*char \\* foo\\(int,.*char.*\\*\\);\r\n\\}\r\n$gdb_prompt $" {
347 kfail "gdb/1512" "ptype fvpchar"
348 }
a0b3c4fd
JM
349}
350
351# print a function from Foo<volatile char *>
352
0b71dc91
DC
353# This test is sensitive to whitespace matching, so we'll do it twice,
354# varying the spacing, because of PR gdb/33.
355
f8d3bf8f
MS
356gdb_test_multiple "print Foo<volatile char *>::foo" "print Foo<volatile char *>::foo" {
357 -re "\\$\[0-9\]* = \\{.*char \\*\\((class |)Foo<(volatile char|char volatile) ?\\*> \\*(| const), int, .*char \\*\\)\\} $hex <Foo<.*char.*\\*>::foo\\(int, .*char.*\\*\\)>\r\n$gdb_prompt $" {
358 pass "print Foo<volatile char *>::foo"
359 }
360 -re "No symbol \"Foo<volatile char \\*>\" in current context.\r\n$gdb_prompt $" {
71c25dea
TT
361 # This used to be a kfail gdb/33 and then kfail gdb/931.
362 fail "print Foo<volatile char *>::foo"
85ca1584 363 }
0b71dc91
DC
364}
365
f8d3bf8f
MS
366gdb_test_multiple "print Foo<volatile char*>::foo" "print Foo<volatile char*>::foo" {
367 -re "\\$\[0-9\]* = \\{.*char \\*\\((class |)Foo<(volatile char|char volatile) ?\\*> \\*(| const), int, .*char \\*\\)\\} $hex <Foo<.*char.*\\*>::foo\\(int, .*char.*\\*\\)>\r\n$gdb_prompt $" {
368 pass "print Foo<volatile char*>::foo"
369 }
370 -re "No symbol \"Foo<volatile char\\*>\" in current context.\r\n$gdb_prompt $" {
71c25dea
TT
371 # This used to be a kfail gdb/33 and then kfail gdb/931.
372 fail "print Foo<volatile char*>::foo"
85ca1584 373 }
a0b3c4fd
JM
374}
375
376# Template Bar<T, int>
377
e6d71bf3 378# same as Foo for g++
bd69fc68 379gdb_test_multiple "ptype/r Bar" "ptype Bar" {
f8d3bf8f
MS
380 -re "type = template <(class |)T, (class |)sz> (class |)Bar \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Bar<int,(\\(int\\)|)1>\r\n\[ \t\]*(class |)Bar<int,(\\(int\\)|)33>\r\n$gdb_prompt $" {
381 pass "ptype Bar"
382 }
383 -re "type = <(class |)T, (class |)sz> (class |)Bar \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\n$gdb_prompt $" {
384 xfail "ptype Bar"
385 }
386 -re "ptype Bar\r\ntype = class Bar<int, ?33> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int bar\\(int, int\\);\r\n}\r\n$gdb_prompt $" {
387 # GCC 3.1, DWARF-2 output.
388 kfail "gdb/57" "ptype Bar"
389 }
390 -re "No symbol \"Bar\" in current context.\r\n$gdb_prompt $" {
391 # GCC 2.95.3, stabs+ output.
392 pass "ptype Bar"
393 }
a0b3c4fd
JM
394}
395
396
397# ptype Bar<int,33>
5a2a0a20 398
bd69fc68 399gdb_test_multiple "ptype/r bint" "ptype bint" {
f8d3bf8f
MS
400 -re "type = (class |)Bar<int, ?(\\(int\\)|)33> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int bar\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" {
401 pass "ptype bint"
402 }
403 -re "type = (class |)Bar<int,(\\(int\\)|)33> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int bar\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" {
404 pass "ptype bint"
405 }
a0b3c4fd
JM
406}
407
408# ptype Bar<int, (4>3)>
409
bd69fc68 410gdb_test_multiple "ptype/r bint2" "ptype bint2" {
f8d3bf8f
MS
411 -re "type = (class |)Bar<int, ?(\\(int\\)|)1> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int bar\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" {
412 pass "ptype bint2"
413 }
414 -re "type = (class |)Bar<int,(\\(int\\)|)1> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int bar\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" {
415 pass "ptype bint2"
416 }
a0b3c4fd
JM
417}
418
419# Template Baz<T, char>
420
e6d71bf3 421# Same as Foo, for g++
bd69fc68 422gdb_test_multiple "ptype/r Baz" "ptype Baz" {
f8d3bf8f
MS
423 -re "type = template <(class |)T, ?(class |)sz> (class |)Baz \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Baz<char,(\\(char\\)|)97>\r\n\[ \t\]*(class |)Baz<int,(\\(char\\)|)115>\r\n$gdb_prompt $" {
424 pass "ptype Baz"
425 }
426 -re "type = <(class |)T, ?(class |)sz> (class |)Baz \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\n$gdb_prompt $" {
427 xfail "ptype Baz"
428 }
429 -re "type = class Baz<int, ?'s'> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int baz\\(int, int\\);\r\n}\r\n$gdb_prompt $" {
430 # GCC 3.1, DWARF-2 output.
431 kfail "gdb/57" "ptype Baz"
432 }
433 -re "type = class Baz<int, ?(\\(char\\))?115> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int baz\\(int, int\\);\r\n}\r\n$gdb_prompt $" {
434 # GCC 3.x, DWARF-2 output, running into gdb/57 and gdb/1512.
435 kfail "gdb/57" "ptype Baz"
436 }
437 -re "No symbol \"Baz\" in current context.\r\n$gdb_prompt $" {
438 # GCC 2.95.3, stabs+ output.
439 pass "ptype Baz"
440 }
a0b3c4fd
JM
441}
442
443
444# ptype Baz<int, 's'>
445
bd69fc68 446gdb_test_multiple "ptype/r bazint" "ptype bazint" {
f8d3bf8f
MS
447 -re "type = (class |)Baz<int, ?(\\(char\\)|)(115|\\'s\\')> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int baz\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" {
448 pass "ptype bazint"
449 }
450 -re "type = (class |)Baz<int,(\\(char\\)|)(115|\\'s\\')> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int baz\\(int, int\\).*;\r\n\\}\r\n$gdb_prompt $" {
451 pass "ptype bazint"
452 }
a0b3c4fd
JM
453}
454
455# ptype Baz<char, 'a'>
456
bd69fc68 457gdb_test_multiple "ptype/r bazint2" "ptype bazint2" {
f8d3bf8f
MS
458 -re "type = (class |)Baz<char, ?(\\(char\\)|)(97|\\'a\\')> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*.*char baz\\(int, char\\);\r\n\\}\r\n$gdb_prompt $" {
459 pass "ptype bazint2"
460 }
461 -re "type = (class |)Baz<char,(\\(char\\)|)(97|\\'a\\')> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*char baz\\(int, char\\);.*\r\n\\}\r\n$gdb_prompt $" {
462 pass "ptype bazint2"
463 }
a0b3c4fd
JM
464}
465
466# Template Qux<T, int (*f)(int) >
e6d71bf3 467# Same as Foo for g++
bd69fc68 468gdb_test_multiple "ptype/r Qux" "ptype Qux" {
f8d3bf8f
MS
469 -re "type = template <(class |)T, ?(class |)sz> (class |)Qux \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Qux<int,&string>\r\n\[ \t\]*(class |)Qux<char,&string>\r\n$gdb_prompt $" {
470 pass "ptype Qux"
471 }
472 -re ".*type = template <(class |)T.*, ?(class |)sz> (class |)Qux \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}.*$gdb_prompt $" {
473 pass "ptype Qux"
474 }
475 -re "type = class Qux<char, ?&string> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*char qux\\(int, char\\);\r\n}\r\n$gdb_prompt $" {
476 # GCC 3.1, DWARF-2 output.
477 kfail "gdb/57" "ptype Qux"
478 }
479 -re "type = class Qux<char, ?&\\(string\\)> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*char qux\\(int, char\\);\r\n}\r\n$gdb_prompt $" {
480 # GCC 3.x, DWARF-2 output; gdb/57 + gdb/1512.
481 kfail "gdb/57" "ptype Qux"
482 }
483 -re "No symbol \"Qux\" in current context.\r\n$gdb_prompt $" {
484 # GCC 2.95.3, stabs+ output.
485 pass "ptype Qux"
486 }
a0b3c4fd
JM
487}
488
489# pt Qux<int,&string>
490
bd69fc68 491gdb_test_multiple "ptype/r quxint" "ptype quxint" {
f8d3bf8f
MS
492 -re "type = class Qux<int, ?& ?string> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int qux\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" {
493 pass "ptype quxint"
494 }
495 -re "type = class Qux<int, ?& ?string> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int qux\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" {
496 pass "ptype quxint"
497 }
498 -re "type = class Qux<int, ?\\(char ?\\*\\)\\(& ?\\(?string\\)?\\)> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int qux\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" {
499 pass "ptype quxint"
500 }
501 -re "type = class Qux<int, ?& ?\\(string\\)> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int qux\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" {
502 kfail "gdb/1512" "ptype quxint"
503 }
a0b3c4fd
JM
504}
505
a0b3c4fd
JM
506
507# Template Spec<T1, T2>
508
e6d71bf3 509# Same as Foo for g++
bd69fc68 510gdb_test_multiple "ptype/r Spec" "ptype Spec" {
f8d3bf8f
MS
511 -re "type = template <(class |)T1, (class |)T2> (class |)Spec \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Spec<int,int \\*>\r\n\[ \t\]*(class |)Spec<int,char>\r\n$gdb_prompt $" {
512 pass "ptype Spec"
513 }
514 -re "type = <(class |)T1, (class |)T2> (class |)Spec \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\\}\r\n$gdb_prompt $" {
515 xfail "ptype Spec"
516 }
517 -re "type = class Spec<int, ?char> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\r\n\[ \t\]*int spec\\(char\\);\r\n}\r\n$gdb_prompt $" {
518 # GCC 3.1, DWARF-2 output.
519 kfail "gdb/57" "ptype Spec"
520 }
521 -re "No symbol \"Spec\" in current context.\r\n$gdb_prompt $" {
522 # GCC 2.95.3, stabs+ output.
523 pass "ptype Spec"
524 }
a0b3c4fd
JM
525}
526
527# pt Spec<char,0>
528
bd69fc68 529gdb_test_multiple "ptype/r siip" "ptype siip" {
f8d3bf8f
MS
530 -re "type = class Spec<int, ?int ?\\*> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\r\n\[ \t\]*.*int spec\\(int ?\\*\\);\r\n\\}\r\n$gdb_prompt $" {
531 pass "ptype siip"
532 }
533 -re "type = class Spec<int,int ?\\*> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\r\n\[ \t\]*int spec\\(int ?\\*\\);.*\r\n\\}\r\n$gdb_prompt $" {
534 pass "ptype siip"
535 }
a0b3c4fd
JM
536}
537
538# pt Garply<int>
539
bd69fc68 540gdb_test_multiple "ptype/r Garply<int>" "ptype Garply<int>" {
f8d3bf8f
MS
541 -re "type = class Garply<int> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int garply\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" {
542 pass "ptype Garply<int>"
543 }
544 -re "type = class Garply<int> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int garply\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" {
545 pass "ptype Garply<int>"
546 }
a0b3c4fd
JM
547}
548
549# ptype of nested template name
550
bd69fc68 551gdb_test_multiple "ptype/r Garply<Garply<char> >" "ptype Garply<Garply<char> >" {
f8d3bf8f
MS
552 -re "type = (class |)Garply<Garply<char> > \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*(class |)Garply<char> t;\r\n\r\n\[ \t\]*.*(class |)Garply<char> garply\\(int, (class |)Garply<char>\\);\r\n\\}\r\n$gdb_prompt $" {
553 pass "ptype Garply<Garply<char> >"
554 }
555 -re "type = (class |)Garply<Garply<char> > \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*(class |)Garply<char> t;\r\n\r\n\[ \t\]*(class |)Garply<char> garply\\(int, (class |)Garply<char>\\);.*\r\n\\}\r\n$gdb_prompt $" {
556 pass "ptype Garply<Garply<char> >"
557 }
a0b3c4fd
JM
558}
559
560# print out a function from a nested template name
561
f8d3bf8f
MS
562gdb_test "print Garply<Garply<char> >::garply" \
563 "\\$\[0-9\]* = \\{(class |)Garply<char> \\((class |)Garply<Garply<char> > \\*(| const), int, (class |)Garply<char>\\)\\} $hex <Garply<Garply<char>\[ \t\]*>::garply\\(int, (class |)Garply<char>\\)>" \
564 "print Garply<Garply<char> >::garply"
a0b3c4fd 565
e6d71bf3
DB
566# djb - 06-03-2000
567# Now should work fine
b598bfda
DJ
568gdb_test "break Garply<Garply<char> >::garply" \
569 "Breakpoint \[0-9\]* at $hex: file .*templates.cc, line.*"
This page took 1.264422 seconds and 4 git commands to generate.