1 # Copyright 1998, 1999, 2007, 2008, 2009 Free Software Foundation, Inc.
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.
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.
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/>.
16 # This file was written by Elena Zannoni (ezannoni@cygnus.com)
18 # This file is part of the gdb testsuite
21 # tests to cover evaluate_subexp_standard with the EVAL_SKIP flag set.
22 # this happens for instance when there is short circuit evaluation in the && and ||
23 # operators, or in the non returned part of a (x ? y: z) expression.
24 # the part that is not evaluated is parsed and evaluated anyway, but with
25 # the EVAL_SKIP flag set
27 # source file "int-type.c"
35 # Check to see if we have an executable to test. If not, then either we
36 # haven't tried to compile one, or the compilation failed for some reason.
37 # In either case, just notify the user and skip the tests in this file.
39 set testfile "int-type"
40 set srcfile ${testfile}.c
41 set binfile ${objdir}/${subdir}/${testfile}
43 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
44 untested eval-skip.exp
48 if [get_compiler_info $binfile] {
54 gdb_reinitialize_dir $srcdir/$subdir
58 if ![runto_main] then {
59 perror "couldn't run to breakpoint"
63 gdb_test "set variable x=14" "" "set variable x=14"
64 gdb_test "set variable y=2" "" "set variable y=2"
65 gdb_test "set variable z=2" "" "set variable z=2"
66 gdb_test "set variable w=3" "" "set variable w=3"
68 send_gdb "print (0 && (x+y))\n"
70 -re ".$decimal = $false\r\n$gdb_prompt $" {
71 pass "print value of (0 && (x+y))"
73 -re ".*$gdb_prompt $" { fail "print value of (0 && (x+y))" }
74 timeout { fail "(timeout) print value of (0 && (x+y))" }
78 send_gdb "print (0 && (x-y))\n"
80 -re ".$decimal = $false\r\n$gdb_prompt $" {
81 pass "print value of (0 && (x-y))"
83 -re ".*$gdb_prompt $" { fail "print value of (0 && (x-y))" }
84 timeout { fail "(timeout) print value of (0 && (x-y))" }
88 send_gdb "print (0 && (x*y))\n"
90 -re ".$decimal = $false\r\n$gdb_prompt $" {
91 pass "print value of (0 && (x*y))"
93 -re ".*$gdb_prompt $" { fail "print value of (0 && (x*y))" }
94 timeout { fail "(timeout) print value of (0 && (x*y))" }
99 send_gdb "print (0 && (x/y))\n"
101 -re ".$decimal = $false\r\n$gdb_prompt $" {
102 pass "print value of (0 && (x/y))"
104 -re ".*$gdb_prompt $" { fail "print value of (0 && (x/y))" }
105 timeout { fail "(timeout) print value of (0 && (x/y))" }
109 send_gdb "print (0 && (x%y))\n"
111 -re ".$decimal = $false\r\n$gdb_prompt $" {
112 pass "print value of (0 && (x%y))"
114 -re ".*$gdb_prompt $" { fail "print value of (0 && (x%y))" }
115 timeout { fail "(timeout) print value of (0 && (x%y))" }
119 send_gdb "print (0 && (x&&y))\n"
121 -re ".$decimal = $false\r\n$gdb_prompt $" {
122 pass "print value of (0 && (x&&y))"
124 -re ".*$gdb_prompt $" { fail "print value of (0 && (x&&y))" }
125 timeout { fail "(timeout) print value of (0 && (x&&y))" }
130 send_gdb "print (0 && (x||y))\n"
132 -re ".$decimal = $false\r\n$gdb_prompt $" {
133 pass "print value of (0 && (x||y))"
135 -re ".*$gdb_prompt $" { fail "print value of (0 && (x||y))" }
136 timeout { fail "(timeout) print value of (0 && (x||y))" }
141 send_gdb "print (0 && (x&y))\n"
143 -re ".$decimal = $false\r\n$gdb_prompt $" {
144 pass "print value of (0 && (x&y))"
146 -re ".*$gdb_prompt $" { fail "print value of (0 && (x&y))" }
147 timeout { fail "(timeout) print value of (0 && (x&y))" }
151 send_gdb "print (0 && (x|y))\n"
153 -re ".$decimal = $false\r\n$gdb_prompt $" {
154 pass "print value of (0 && (x|y))"
156 -re ".*$gdb_prompt $" { fail "print value of (0 && (x|y))" }
157 timeout { fail "(timeout) print value of (0 && (x|y))" }
161 send_gdb "print (0 && (x^y))\n"
163 -re ".$decimal = $false\r\n$gdb_prompt $" {
164 pass "print value of (0 && (x^y))"
166 -re ".*$gdb_prompt $" { fail "print value of (0 && (x^y))" }
167 timeout { fail "(timeout) print value of (0 && (x^y))" }
172 send_gdb "print (0 && (x < y))\n"
174 -re ".$decimal = $false\r\n$gdb_prompt $" {
175 pass "print value of (0 && (x < y))"
177 -re ".*$gdb_prompt $" { fail "print value of (0 && (x < y))" }
178 timeout { fail "(timeout) print value of (0 && (x < y))" }
182 send_gdb "print (0 && (x <= y))\n"
184 -re ".$decimal = $false\r\n$gdb_prompt $" {
185 pass "print value of (0 && (x <= y))"
187 -re ".*$gdb_prompt $" { fail "print value of (0 && (x <= y))" }
188 timeout { fail "(timeout) print value of (0 && (x <= y))" }
193 send_gdb "print (0 && (x>y))\n"
195 -re ".$decimal = $false\r\n$gdb_prompt $" {
196 pass "print value of (0 && (x>y))"
198 -re ".*$gdb_prompt $" { fail "print value of (0 && (x>y))" }
199 timeout { fail "(timeout) print value of (0 && (x>y))" }
203 send_gdb "print (0 && (x>=y))\n"
205 -re ".$decimal = $false\r\n$gdb_prompt $" {
206 pass "print value of (0 && (x>=y))"
208 -re ".*$gdb_prompt $" { fail "print value of (0 && (x>=y))" }
209 timeout { fail "(timeout) print value of (0 && (x>=y))" }
214 send_gdb "print (0 && (x==y))\n"
216 -re ".$decimal = $false\r\n$gdb_prompt $" {
217 pass "print value of (0 && (x==y))"
219 -re ".*$gdb_prompt $" { fail "print value of (0 && (x==y))" }
220 timeout { fail "(timeout) print value of (0 && (x==y))" }
224 send_gdb "print (0 && (x!=y))\n"
226 -re ".$decimal = $false\r\n$gdb_prompt $" {
227 pass "print value of (0 && (x!=y))"
229 -re ".*$gdb_prompt $" { fail "print value of (0 && (x!=y))" }
230 timeout { fail "(timeout) print value of (0 && (x!=y))" }
234 send_gdb "print (0 && (x<<31))\n"
236 -re ".$decimal = $false\r\n$gdb_prompt $" {
237 pass "print value of (0 && (x<<31))"
239 -re ".*$gdb_prompt $" { fail "print value of (0 && (x<<31))" }
240 timeout { fail "(timeout) print value of (0 && (x<<31))" }
244 send_gdb "print (0 && (x>>31))\n"
246 -re ".$decimal = $false\r\n$gdb_prompt $" {
247 pass "print value of (0 && (x>>31))"
249 -re ".*$gdb_prompt $" { fail "print value of (0 && (x>>31))" }
250 timeout { fail "(timeout) print value of (0 && (x>>31))" }
255 send_gdb "print (0 && (!x))\n"
257 -re ".$decimal = $false\r\n$gdb_prompt $" {
258 pass "print value of (0 && (!x))"
260 -re ".*$gdb_prompt $" { fail "print value of (0 && (!x))" }
261 timeout { fail "(timeout) print value of (0 && (!x))" }
265 send_gdb "print (0 && (~x))\n"
267 -re ".$decimal = $false\r\n$gdb_prompt $" {
268 pass "print value of (0 && (~x))"
270 -re ".*$gdb_prompt $" { fail "print value of (0 && (~x))" }
271 timeout { fail "(timeout) print value of (0 && (~x))" }
274 send_gdb "print (0 && (-x))\n"
276 -re ".$decimal = $false\r\n$gdb_prompt $" {
277 pass "print value of (0 && (-x))"
279 -re ".*$gdb_prompt $" { fail "print value of (0 && (-x))" }
280 timeout { fail "(timeout) print value of (0 && (-x))" }
284 send_gdb "print (0 && (x++))\n"
286 -re ".$decimal = $false\r\n$gdb_prompt $" {
287 pass "print value of (0 && (x++))"
289 -re ".*$gdb_prompt $" { fail "print value of (0 && (x++))" }
290 timeout { fail "(timeout) print value of (0 && (x++))" }
294 send_gdb "print (0 && (++x))\n"
296 -re ".$decimal = $false\r\n$gdb_prompt $" {
297 pass "print value of (0 && (++x))"
299 -re ".*$gdb_prompt $" { fail "print value of (0 && (++x))" }
300 timeout { fail "(timeout) print value of (0 && (++x))" }
304 send_gdb "print (0 && (x--))\n"
306 -re ".$decimal = $false\r\n$gdb_prompt $" {
307 pass "print value of (0 && (x--))"
309 -re ".*$gdb_prompt $" { fail "print value of (0 && (x--))" }
310 timeout { fail "(timeout) print value of (0 && (x--))" }
314 send_gdb "print (0 && (--x))\n"
316 -re ".$decimal = $false\r\n$gdb_prompt $" {
317 pass "print value of (0 && (--x))"
319 -re ".*$gdb_prompt $" { fail "print value of (0 && (--x))" }
320 timeout { fail "(timeout) print value of (0 && (--x))" }
323 send_gdb "print (0 && (x+=7))\n"
325 -re ".$decimal = $false\r\n$gdb_prompt $" {
326 pass "print value of (0 && (x+=7))"
328 -re ".*$gdb_prompt $" { fail "print value of (0 && (x+=7))" }
329 timeout { fail "(timeout) print value of (0 && (x+=7))" }
332 send_gdb "print (0 && (x=y))\n"
334 -re ".$decimal = $false\r\n$gdb_prompt $" {
335 pass "print value of (0 && (x=y))"
337 -re ".*$gdb_prompt $" { fail "print value of (0 && (x=y))" }
338 timeout { fail "(timeout) print value of (0 && (x=y))" }