1 # Copyright 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2007,
2 # 2008, 2009 Free Software Foundation, Inc.
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
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # This file was written by Fred Fish. (fnf@cygnus.com)
25 if { [skip_cplus_tests] } { continue }
27 set testfile "templates"
28 set srcfile ${testfile}.cc
29 set binfile ${objdir}/${subdir}/${testfile}
31 # Create and source the file that provides information about the compiler
32 # used to compile the test case.
33 if [get_compiler_info ${binfile} "c++"] {
37 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
38 untested templates.exp
43 # Test printing of the types of templates.
46 proc test_ptype_of_templates {} {
50 send_gdb "ptype T5<int>\n"
52 -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 $" {
55 -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 $" {
58 -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 $" { pass "ptype T5<int> -- new with unsigned int" }
59 -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 $" { pass "ptype T5<int> -- new with unsigned long" }
60 -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 $" {
61 pass "ptype T5<int> (obsolescent gcc or gdb)"
63 -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\\(unsigned( int| long|)\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" {
64 # This also triggers gdb/1113...
65 kfail "gdb/1111" "ptype T5<int>"
67 -re ".*$gdb_prompt $" {
71 fail "ptype T5<int> (timeout)"
75 send_gdb "ptype t5i\n"
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\\(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 $" { pass "ptype T5<int> -- with several fixes from 4.17" }
78 -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 $" { pass "ptype t5i<int> -- new with unsigned int" }
79 -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 $" { pass "ptype t5i<int> -- new with unsigned long" }
80 -re "type = class T5<int> \{.*public:.*static int X;.*int x;.*int val;.*.*T5 \\(int\\);.*.*void ~T5 \\(int\\).*.*.*int value \\((void|)\\);.*\}.*$gdb_prompt $" {
83 -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 $" {
86 -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 $" {
89 -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 $" {
90 pass "ptype t5i (obsolescent gcc or gdb)"
92 -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\\(unsigned( int| long|)\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" {
93 # This also triggers gdb/1113...
94 kfail "gdb/1111" "ptype T5<int>"
96 -re ".*$gdb_prompt $" {
100 fail "ptype t5i (timeout)"
106 # Test breakpoint setting on template methods.
109 proc test_template_breakpoints {} {
113 global hp_aCC_compiler
115 gdb_test_multiple "break T5<int>::T5" "constructor breakpoint" {
116 -re "0. cancel.*\[\r\n\]*.1. all.*\[\r\n\]*.2. T5<int>::T5\\(int\\) at .*\[\r\n\]*.3. T5<int>::T5\\((T5<int> const|const T5<int>) ?&\\) at .*\[\r\n\]*> $" {
119 "constructor breakpoint (obsolete format!)"
121 -re ".0. cancel\[\r\n\]*.1. all\[\r\n\]*.2. T5<int>::T5\\((T5<int> const|const T5<int>) ?&\\) at .*templates.cc:.*\[\r\n\]*.3. T5<int>::T5\\(int\\) at .*templates.cc:.*\[\r\n\]*> $" {
124 "constructor breakpoint"
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" "*-*-*"
129 "nonsense intended to insure that this test fails" \
130 "constructor breakpoint"
134 "nonsense intended to insure that this test fails" \
135 "constructor breakpoint (bad menu choices)"
140 if {$hp_aCC_compiler} {setup_xfail hppa*-*-* CLLbs14792}
142 gdb_test_multiple "break T5<int>::~T5" "destructor_breakpoint" {
143 -re "Breakpoint.*at.* file .*${testfile}.cc, line.*$gdb_prompt $"
145 pass "destructor breakpoint"
147 -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 $"
149 kfail "gdb/1112" "destructor breakpoint"
153 gdb_test "break T5<int>::value" \
154 "Breakpoint.*at.* file .*${testfile}.cc, line.*" \
155 "value method breakpoint"
157 set bp_location [gdb_get_line_number \
158 "set breakpoint on a line with no real code"]
159 gdb_test "break ${testfile}.cc:${bp_location}" \
160 "Breakpoint.*at.* file .*${testfile}.cc, line.*(2 locations).*" \
161 "breakpoint on a line with no real code"
166 # Test calling of template methods.
169 proc test_template_calls {} {
171 global hp_aCC_compiler
173 if [target_info exists gdb,cannot_call_functions] {
174 setup_xfail "*-*-*" 2416
175 fail "This target can not call functions"
179 if {!$hp_aCC_compiler} {setup_xfail hppa*-*-*}
180 send_gdb "print t5i.value()\n"
182 -re ".* = 2\[\r\n\]*$gdb_prompt $" { pass "print t5i.value()" }
183 -re "Cannot invoke functions on this machine.*$gdb_prompt $" {
184 fail "print t5i.value()"
186 -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" {
187 setup_xfail hppa*-*-* CLLbs16899
188 xfail "print t5i.value"
190 -re ".*$gdb_prompt $" { fail "print t5i.value()" }
191 timeout { fail "print t5i.value() (timeout)" }
195 proc test_template_typedef {} {
197 gdb_test "print intBazOne::baz" ".*baz\\(int, int\\)>" \
198 "print method of template typedef"
200 gdb_test "print intBazOne::~Baz" ".*~Baz(\\(\\))?>" \
201 "print destructor of template typedef"
216 # Start with a fresh gdb.
220 gdb_reinitialize_dir $srcdir/$subdir
223 # Change multiple-symbols to "ask" in order to get the multiple-choice
224 # menu when breaking on overloaded methods.
225 gdb_test "set multiple-symbols ask" ""
229 test_ptype_of_templates
230 test_template_breakpoints
231 test_template_typedef
241 # More tests for different kinds of template parameters,
242 # templates with partial specializations, nested templates, etc.
243 # These have been tested only with HP aCC. They probably won't
244 # work with other compilers because of differences in mangling
246 # Added by Satish Pai <pai@apollo.hp.com> 1997-09-25
247 # As of 2000-06-03, C++ support has been improved to the point that g++ can
248 # pass all of theses, excluding what appears to be one that exposes a stabs bug. - djb
250 # I don't know how HP could be passing these tests without this. They
251 # weren't breakpointing past a point where the below expressions were
252 # initialized in the actual source. - djb
256 -re ".*$gdb_prompt $"
260 -re ".*$gdb_prompt $"
262 send_gdb "print fint\n"
264 -re "\\$\[0-9\]* = \\{x = 0, t = 0\\}\r\n$gdb_prompt $" { pass "print fint" }
265 -re "$gdb_prompt $" { fail "print fint" }
266 timeout { fail "(timeout) print fint" }
269 send_gdb "print fvpchar\n"
271 -re "\\$\[0-9\]* = \\{x = 0, t = 0x0\\}\r\n$gdb_prompt $" { pass "print fvpchar" }
272 -re "$gdb_prompt $" { fail "print fvpchar" }
273 timeout { fail "(timeout) print fvpchar" }
278 # Neither stabs nor DWARF-2 contains type information about templates
279 # (as opposed to instantiations of templates), so in those
280 # circumstances we expect GDB to not find a symbol. HP has a debug
281 # format that contains more info, though, so it's also correct to
282 # print out template info. (This affects several subsequent tests as
285 # NOTE: carlton/2003-02-26: However, because of a bug in the way GDB
286 # handles nested types, we don't get this right in the DWARF-2 case.
288 send_gdb "ptype Foo\n"
290 -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 $" { pass "ptype Foo" }
291 -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 $" { xfail "ptype Foo" }
292 -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 $"
293 { # GCC 3.1, DWARF-2 output.
294 kfail "gdb/57" "ptype Foo" }
295 -re "No symbol \"Foo\" in current context.\r\n$gdb_prompt $"
296 { # GCC 2.95.3, stabs+ output.
298 -re "$gdb_prompt $" { fail "ptype Foo" }
299 timeout { fail "(timeout) ptype Foo" }
301 # -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 $"
305 send_gdb "ptype fint\n"
307 -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 $" { pass "ptype fint" }
308 -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 $" { pass "ptype fint" }
309 -re "$gdb_prompt $" { fail "ptype fint" }
310 timeout { fail "(timeout) ptype fint" }
315 send_gdb "ptype fchar\n"
317 -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 $" { pass "ptype fchar" }
318 -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 $" { pass "ptype fchar" }
319 -re "$gdb_prompt $" { fail "ptype fchar" }
320 timeout { fail "(timeout) ptype fchar" }
323 # ptype Foo<volatile char *>
325 send_gdb "ptype fvpchar\n"
327 -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 $" { pass "ptype fvpchar" }
328 -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 $" { pass "ptype fvpchar" }
329 -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 $" {
330 kfail "gdb/1512" "ptype fvpchar"
332 -re "$gdb_prompt $" { fail "ptype fvpchar" }
333 timeout { fail "(timeout) ptype fvpchar" }
336 # print a function from Foo<volatile char *>
338 # This test is sensitive to whitespace matching, so we'll do it twice,
339 # varying the spacing, because of PR gdb/33.
341 send_gdb "print Foo<volatile char *>::foo\n"
343 -re "\\$\[0-9\]* = \\{.*char \\*\\((class |)Foo<(volatile char|char volatile) ?\\*> \\*(| const), int, .*char \\*\\)\\} $hex <Foo<.*char.*\\*>::foo\\(int, .*char.*\\*\\)>\r\n$gdb_prompt $" { pass "print Foo<volatile char *>::foo" }
344 -re "No symbol \"Foo<volatile char \\*>\" in current context.\r\n$gdb_prompt $"
346 # This used to be a kfail gdb/33 and then kfail gdb/931.
347 fail "print Foo<volatile char *>::foo"
349 -re "$gdb_prompt $" { fail "print Foo<volatile char *>::foo" }
350 timeout { fail "(timeout) print Foo<volatile char *>::foo" }
353 send_gdb "print Foo<volatile char*>::foo\n"
355 -re "\\$\[0-9\]* = \\{.*char \\*\\((class |)Foo<(volatile char|char volatile) ?\\*> \\*(| const), int, .*char \\*\\)\\} $hex <Foo<.*char.*\\*>::foo\\(int, .*char.*\\*\\)>\r\n$gdb_prompt $" { pass "print Foo<volatile char*>::foo" }
356 -re "No symbol \"Foo<volatile char\\*>\" in current context.\r\n$gdb_prompt $"
358 # This used to be a kfail gdb/33 and then kfail gdb/931.
359 fail "print Foo<volatile char*>::foo"
361 -re "$gdb_prompt $" { fail "print Foo<volatile char*>::foo" }
362 timeout { fail "(timeout) print Foo<volatile char*>::foo" }
365 # Template Bar<T, int>
367 # same as Foo for g++
368 send_gdb "ptype Bar\n"
370 -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 $" { pass "ptype Bar" }
371 -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 $" { xfail "ptype Bar" }
372 -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 $"
373 { # GCC 3.1, DWARF-2 output.
374 kfail "gdb/57" "ptype Bar" }
375 -re "No symbol \"Bar\" in current context.\r\n$gdb_prompt $"
376 { # GCC 2.95.3, stabs+ output.
378 -re "$gdb_prompt $" { fail "ptype Bar" }
379 timeout { fail "(timeout) ptype Bar" }
385 send_gdb "ptype bint\n"
387 -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 $" { pass "ptype bint" }
388 -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 $" { pass "ptype bint" }
389 -re "$gdb_prompt $" { fail "ptype bint" }
390 timeout { fail "(timeout) ptype bint" }
393 # ptype Bar<int, (4>3)>
395 send_gdb "ptype bint2\n"
397 -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 $" { pass "ptype bint2" }
398 -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 $" { pass "ptype bint2" }
399 -re "$gdb_prompt $" { fail "ptype bint2" }
400 timeout { fail "(timeout) ptype bint2" }
403 # Template Baz<T, char>
405 # Same as Foo, for g++
406 send_gdb "ptype Baz\n"
408 -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 $" { pass "ptype Baz" }
409 -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 $" { xfail "ptype Baz" }
410 -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 $"
411 { # GCC 3.1, DWARF-2 output.
412 kfail "gdb/57" "ptype Baz" }
413 -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 $"
414 { # GCC 3.x, DWARF-2 output, running into gdb/57 and gdb/1512.
415 kfail "gdb/57" "ptype Baz" }
416 -re "No symbol \"Baz\" in current context.\r\n$gdb_prompt $"
417 { # GCC 2.95.3, stabs+ output.
419 -re "$gdb_prompt $" { fail "ptype Baz" }
420 timeout { fail "(timeout) ptype Baz" }
424 # ptype Baz<int, 's'>
426 send_gdb "ptype bazint\n"
428 -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 $" { pass "ptype bazint" }
429 -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 $" { pass "ptype bazint" }
430 -re "$gdb_prompt $" { fail "ptype bazint" }
431 timeout { fail "(timeout) ptype bazint" }
434 # ptype Baz<char, 'a'>
436 send_gdb "ptype bazint2\n"
438 -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 $" { pass "ptype bazint2" }
439 -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 $" { pass "ptype bazint2" }
440 -re "$gdb_prompt $" { fail "ptype bazint2" }
441 timeout { fail "(timeout) ptype bazint2" }
444 # Template Qux<T, int (*f)(int) >
445 # Same as Foo for g++
446 send_gdb "ptype Qux\n"
448 -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 $" { pass "ptype Qux" }
449 -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 $" { pass "ptype Qux" }
450 -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 $"
451 { # GCC 3.1, DWARF-2 output.
452 kfail "gdb/57" "ptype Qux" }
453 -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 $"
454 { # GCC 3.x, DWARF-2 output; gdb/57 + gdb/1512.
455 kfail "gdb/57" "ptype Qux" }
456 -re "No symbol \"Qux\" in current context.\r\n$gdb_prompt $"
457 { # GCC 2.95.3, stabs+ output.
459 -re "$gdb_prompt $" { fail "ptype Qux" }
460 timeout { fail "(timeout) ptype Qux" }
463 # pt Qux<int,&string>
465 send_gdb "ptype quxint\n"
467 -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 $" { pass "ptype quxint" }
468 -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 $" { pass "ptype quxint" }
469 -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 $" { pass "ptype quxint" }
470 -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 $" {
471 kfail "gdb/1512" "ptype quxint"
473 -re "$gdb_prompt $" { fail "ptype quxint" }
474 timeout { fail "(timeout) ptype quxint" }
479 # commented out this as quxint2 declaration was commented out in
480 # templates.exp -- ovidiu
481 # send_gdb "ptype quxint2\n"
483 # -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 $" { pass "ptype quxint2" }
484 # -re "$gdb_prompt $" { fail "ptype quxint2" }
485 # timeout { fail "(timeout) ptype quxint2" }
488 # Template Spec<T1, T2>
490 # Same as Foo for g++
491 send_gdb "ptype Spec\n"
493 -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 $" { pass "ptype Spec" }
494 -re "type = <(class |)T1, (class |)T2> (class |)Spec \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\\}\r\n$gdb_prompt $" { xfail "ptype Spec" }
495 -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 $"
496 { # GCC 3.1, DWARF-2 output.
497 kfail "gdb/57" "ptype Spec" }
498 -re "No symbol \"Spec\" in current context.\r\n$gdb_prompt $"
499 { # GCC 2.95.3, stabs+ output.
501 -re "$gdb_prompt $" { fail "ptype Spec" }
502 timeout { fail "(timeout) ptype Spec" }
507 send_gdb "ptype siip\n"
509 -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 $" { pass "ptype siip" }
510 -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 $" { pass "ptype siip" }
511 -re "$gdb_prompt $" { fail "ptype siip" }
512 timeout { fail "(timeout) ptype siip" }
517 send_gdb "ptype Garply<int>\n"
519 -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 $" { pass "ptype Garply<int>" }
520 -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 $" { pass "ptype Garply<int>" }
521 -re "$gdb_prompt $" { fail "ptype Garply<int>" }
522 timeout { fail "(timeout) ptype Garply<int>" }
525 # ptype of nested template name
527 send_gdb "ptype Garply<Garply<char> >\n"
529 -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 $" { pass "ptype Garply<Garply<char> >" }
530 -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 $" { pass "ptype Garply<Garply<char> >" }
531 -re "$gdb_prompt $" { fail "ptype Garply<Garply<char> >" }
532 timeout { fail "(timeout) ptype Garply<Garply<char> >" }
535 # print out a function from a nested template name
537 send_gdb "print Garply<Garply<char> >::garply\n"
539 -re "\\$\[0-9\]* = \\{(class |)Garply<char> \\((class |)Garply<Garply<char> > \\*(| const), int, (class |)Garply<char>\\)\\} $hex <Garply<Garply<char>\[ \t\]*>::garply\\(int, (class |)Garply<char>\\)>\r\n$gdb_prompt $" { pass "print Garply<Garply<char> >::garply" }
540 -re ".*$gdb_prompt $" { fail "print Garply<Garply<char> >::garply" }
541 timeout { fail "print Garply<Garply<char> >::garply (timeout)" }
545 # Now should work fine
546 gdb_test "break Garply<Garply<char> >::garply" \
547 "Breakpoint \[0-9\]* at $hex: file .*templates.cc, line.*"