Commit | Line | Data |
---|---|---|
96da2469 | 1 | # Copyright 1998, 1999, 2001, 2003, 2004 Free Software Foundation, Inc. |
a0b3c4fd JM |
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 2 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, write to the Free Software | |
15 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
16 | ||
17 | # Please email any bugs, comments, and/or additions to this file to: | |
18 | # bug-gdb@prep.ai.mit.edu | |
19 | ||
a0b3c4fd JM |
20 | # This file is part of the gdb testsuite |
21 | # file written by Elena Zannoni (ezannoni@cygnus.com) | |
96da2469 | 22 | # rewritten by Michael Chastain (mec.gnu@mindspring.com) |
a0b3c4fd JM |
23 | # |
24 | # source files cttiadd.cc, cttiadd1.cc, cttiadd2.cc, cttiadd3.cc | |
a0b3c4fd | 25 | |
96da2469 | 26 | # Call to template instantiations. |
a0b3c4fd JM |
27 | |
28 | if $tracelevel then { | |
96da2469 | 29 | strace $tracelevel |
a0b3c4fd JM |
30 | } |
31 | ||
fc33412a | 32 | if { [skip_cplus_tests] } { continue } |
55b13a65 | 33 | |
a0b3c4fd | 34 | set testfile "cttiadd" |
96da2469 MC |
35 | set srcfile "${srcdir}/${subdir}/${testfile}.cc" |
36 | set srcfile1 "${srcdir}/${subdir}/${testfile}1.cc" | |
37 | set srcfile2 "${srcdir}/${subdir}/${testfile}2.cc" | |
38 | set srcfile3 "${srcdir}/${subdir}/${testfile}3.cc" | |
39 | set objfile "${objdir}/${subdir}/${testfile}.o" | |
40 | set objfile1 "${objdir}/${subdir}/${testfile}1.o" | |
41 | set objfile2 "${objdir}/${subdir}/${testfile}2.o" | |
42 | set objfile3 "${objdir}/${subdir}/${testfile}3.o" | |
43 | set binfile "${objdir}/${subdir}/${testfile}" | |
44 | ||
45 | if { [gdb_compile "${srcfile}" "${objfile}" object {debug c++}] != "" } { | |
46 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
47 | } | |
a0b3c4fd | 48 | |
96da2469 MC |
49 | if { [gdb_compile "${srcfile1}" "${objfile1}" object {debug c++}] != "" } { |
50 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
a0b3c4fd JM |
51 | } |
52 | ||
96da2469 MC |
53 | if { [gdb_compile "${srcfile2}" "${objfile2}" object {debug c++}] != "" } { |
54 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
55 | } | |
a0b3c4fd | 56 | |
96da2469 MC |
57 | if { [gdb_compile "${srcfile3}" "${objfile3}" object {debug c++}] != "" } { |
58 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
59 | } | |
a0b3c4fd | 60 | |
96da2469 MC |
61 | if { [gdb_compile "${objfile} ${objfile1} ${objfile2} ${objfile3}" "${binfile}" executable {debug c++}] != "" } { |
62 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
63 | } | |
a0b3c4fd | 64 | |
96da2469 MC |
65 | if [get_compiler_info ${binfile} "c++"] { |
66 | return -1; | |
67 | } | |
a0b3c4fd JM |
68 | |
69 | gdb_exit | |
70 | gdb_start | |
71 | gdb_reinitialize_dir $srcdir/$subdir | |
72 | gdb_load ${binfile} | |
73 | ||
a0b3c4fd JM |
74 | if ![runto_main] then { |
75 | perror "couldn't run to breakpoint" | |
76 | continue | |
77 | } | |
78 | ||
96da2469 MC |
79 | # TODO: this needs more work before actually deploying it. |
80 | # So bail out here. | |
81 | ||
82 | if { [ test_compiler_info gcc-*] } then { continue } | |
83 | ||
84 | gdb_test "next" "$decimal.*i = 2;" "next 1" | |
85 | gdb_test "next" "$decimal.*f = 4.5;" "next 2" | |
86 | gdb_test "next" "$decimal.*c = add\\(c, c\\);" "next 3" | |
87 | gdb_test "next" "$decimal.*i = add\\(i, i\\);" "next 4" | |
88 | gdb_test "next" "$decimal.*f = add\\(f, f\\);" "next 5" | |
89 | gdb_test "next" "$decimal.*add1\\(\\);" "next 6" | |
90 | ||
91 | gdb_test "print c" "\\$\[0-9\]+ = -62 .*" | |
92 | gdb_test "print f" "\\$\[0-9\]+ = 9" | |
93 | gdb_test "print i" "\\$\[0-9\]+ = 4" | |
94 | ||
95 | gdb_test_multiple "print add<int>(2,2)" "print add<int>(2,2)" { | |
96 | -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" { | |
97 | pass "print add<int>(2,2)" | |
98 | } | |
99 | -re "No symbol \"add<int>\" in current context.\r\n$gdb_prompt $" { | |
100 | # TODO: kfail or xfail this | |
101 | fail "print add<int>(2,2)" | |
102 | } | |
103 | } | |
a0b3c4fd | 104 | |
96da2469 MC |
105 | # Note: 2.25 and 4.5 are exactly representable in IEEE-ish formats |
106 | gdb_test_multiple "print add<float>(2.25,2.25)" "print add<float>(2.25,2.25)" { | |
107 | -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" { | |
108 | pass "print add<float>(2.25,2.25)" | |
109 | } | |
110 | -re "No symbol \"add<float>\" in current context.\r\n$gdb_prompt $" { | |
111 | # TODO: kfail or xfail this | |
112 | fail "print add<float>(2.25,2.25)" | |
113 | } | |
114 | } | |
a0b3c4fd | 115 | |
96da2469 MC |
116 | gdb_test_multiple "print add<char>('A','A')" "print add<char>('A','A')" { |
117 | -re "\\$\[0-9\]+ = -126 .*\r\n$gdb_prompt $" { | |
118 | pass "print add<char>('A','A')" | |
119 | } | |
120 | -re "No symbol \"add<char>\" in current context.\r\n$gdb_prompt $" { | |
121 | # TODO: kfail or xfail this | |
122 | fail "print add<char>('A','A')" | |
123 | } | |
124 | } | |
a0b3c4fd | 125 | |
96da2469 MC |
126 | gdb_test_multiple "print add2<int>(2,2)" "print add2<int>(2,2)" { |
127 | -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" { | |
128 | pass "print add2<int>(2,2)" | |
129 | } | |
130 | -re "No symbol \"add2<int>\" in current context.\r\n$gdb_prompt $" { | |
131 | # TODO: kfail or xfail this | |
132 | fail "print add2<int>(2,2)" | |
133 | } | |
134 | } | |
a0b3c4fd | 135 | |
96da2469 MC |
136 | gdb_test_multiple "print add2<float>(2.25,2.25)" "print add2<float>(2.25,2.25)" { |
137 | -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" { | |
138 | pass "print add2<float>(2.25,2.25)" | |
139 | } | |
140 | -re "No symbol \"add2<float>\" in current context.\r\n$gdb_prompt $" { | |
141 | # TODO: kfail or xfail this | |
142 | fail "print add2<float>(2.25,2.25)" | |
143 | } | |
144 | } | |
a0b3c4fd | 145 | |
96da2469 MC |
146 | gdb_test_multiple "print add2<char>('A','A')" "print add2<char>('A','A')" { |
147 | -re "\\$\[0-9]+ = -126 .*$gdb_prompt $" { | |
148 | pass "print add2<char>('A','A')" | |
149 | } | |
150 | -re "No symbol \"add2<char>\" in current context.\r\n$gdb_prompt $" { | |
151 | # TODO: kfail or xfail this | |
152 | fail "print add2<char>('A','A')" | |
153 | } | |
154 | } | |
a0b3c4fd | 155 | |
96da2469 MC |
156 | gdb_test_multiple "print add3<int>(2,2)" "print add3<int>(2,2)" { |
157 | -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" { | |
158 | pass "print add3<int>(2,2)" | |
159 | } | |
160 | -re "No symbol \"add3<int>\" in current context.\r\n$gdb_prompt $" { | |
161 | # TODO: kfail or xfail this | |
162 | fail "print add3<int>(2,2)" | |
163 | } | |
164 | } | |
a0b3c4fd | 165 | |
96da2469 MC |
166 | gdb_test_multiple "print add3<float>(2.25,2.25)" "print add3<float>(2.25,2.25)" { |
167 | -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" { | |
168 | pass "print add3<float>(2.25,2.25)" | |
169 | } | |
170 | -re "No symbol \"add3<float>\" in current context.\r\n$gdb_prompt $" { | |
171 | # TODO: kfail or xfail this | |
172 | fail "print add3<float>(2.25,2.25)" | |
173 | } | |
174 | } | |
a0b3c4fd | 175 | |
96da2469 MC |
176 | gdb_test_multiple "print add3<char>('A','A')" "print add3<char>('A','A')" { |
177 | -re "\\$\[0-9]+ = -126 .*$gdb_prompt $" { | |
178 | pass "print add3<char>('A','A')" | |
179 | } | |
180 | -re "No symbol \"add3<char>\" in current context.\r\n$gdb_prompt $" { | |
181 | # TODO: kfail or xfail this | |
182 | fail "print add3<char>('A','A')" | |
183 | } | |
184 | } | |
a0b3c4fd | 185 | |
96da2469 MC |
186 | gdb_test_multiple "print add4<int>(2,2)" "print add4<int>(2,2)" { |
187 | -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" { | |
188 | pass "print add4<int>(2,2)" | |
189 | } | |
190 | -re "No symbol \"add4<int>\" in current context.\r\n$gdb_prompt $" { | |
191 | # TODO: kfail or xfail this | |
192 | fail "print add4<int>(2,2)" | |
193 | } | |
194 | } | |
a0b3c4fd | 195 | |
96da2469 MC |
196 | gdb_test_multiple "print add4<float>(2.25,2.25)" "print add4<float>(2.25,2.25)" { |
197 | -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" { | |
198 | pass "print add4<float>(2.25,2.25)" | |
199 | } | |
200 | -re "No symbol \"add4<float>\" in current context.\r\n$gdb_prompt $" { | |
201 | # TODO: kfail or xfail this | |
202 | fail "print add4<float>(2.25,2.25)" | |
203 | } | |
204 | } | |
a0b3c4fd | 205 | |
96da2469 MC |
206 | gdb_test_multiple "print add4<char>('A','A')" "print add4<char>('A','A')" { |
207 | -re "\\$\[0-9]+ = -126 .*$gdb_prompt $" { | |
208 | pass "print add4<char>('A','A')" | |
209 | } | |
210 | -re "No symbol \"add4<char>\" in current context.\r\n$gdb_prompt $" { | |
211 | # TODO: kfail or xfail this | |
212 | fail "print add4<char>('A','A')" | |
213 | } | |
214 | } |