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