1 # Copyright 1998, 1999, 2007 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 2 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, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 # This file was written by Elena Zannoni (ezannoni@cygnus.com)
22 # This file is part of the gdb testsuite
25 # tests to cover evaluate_subexp_standard with the EVAL_SKIP flag set.
26 # this happens for instance when there is short circuit evaluation in the && and ||
27 # operators, or in the non returned part of a (x ? y: z) expression.
28 # the part that is not evaluated is parsed and evaluated anyway, but with
29 # the EVAL_SKIP flag set
31 # source file "int-type.c"
39 # Check to see if we have an executable to test. If not, then either we
40 # haven't tried to compile one, or the compilation failed for some reason.
41 # In either case, just notify the user and skip the tests in this file.
43 set testfile "int-type"
44 set srcfile ${testfile}.c
45 set binfile ${objdir}/${subdir}/${testfile}
47 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
48 untested eval-skip.exp
52 if [get_compiler_info $binfile] {
58 gdb_reinitialize_dir $srcdir/$subdir
62 if ![runto_main] then {
63 perror "couldn't run to breakpoint"
67 gdb_test "set variable x=14" "" "set variable x=14"
68 gdb_test "set variable y=2" "" "set variable y=2"
69 gdb_test "set variable z=2" "" "set variable z=2"
70 gdb_test "set variable w=3" "" "set variable w=3"
72 send_gdb "print (0 && (x+y))\n"
74 -re ".$decimal = $false\r\n$gdb_prompt $" {
75 pass "print value of (0 && (x+y))"
77 -re ".*$gdb_prompt $" { fail "print value of (0 && (x+y))" }
78 timeout { fail "(timeout) print value of (0 && (x+y))" }
82 send_gdb "print (0 && (x-y))\n"
84 -re ".$decimal = $false\r\n$gdb_prompt $" {
85 pass "print value of (0 && (x-y))"
87 -re ".*$gdb_prompt $" { fail "print value of (0 && (x-y))" }
88 timeout { fail "(timeout) print value of (0 && (x-y))" }
92 send_gdb "print (0 && (x*y))\n"
94 -re ".$decimal = $false\r\n$gdb_prompt $" {
95 pass "print value of (0 && (x*y))"
97 -re ".*$gdb_prompt $" { fail "print value of (0 && (x*y))" }
98 timeout { fail "(timeout) print value of (0 && (x*y))" }
103 send_gdb "print (0 && (x/y))\n"
105 -re ".$decimal = $false\r\n$gdb_prompt $" {
106 pass "print value of (0 && (x/y))"
108 -re ".*$gdb_prompt $" { fail "print value of (0 && (x/y))" }
109 timeout { fail "(timeout) print value of (0 && (x/y))" }
113 send_gdb "print (0 && (x%y))\n"
115 -re ".$decimal = $false\r\n$gdb_prompt $" {
116 pass "print value of (0 && (x%y))"
118 -re ".*$gdb_prompt $" { fail "print value of (0 && (x%y))" }
119 timeout { fail "(timeout) print value of (0 && (x%y))" }
123 send_gdb "print (0 && (x&&y))\n"
125 -re ".$decimal = $false\r\n$gdb_prompt $" {
126 pass "print value of (0 && (x&&y))"
128 -re ".*$gdb_prompt $" { fail "print value of (0 && (x&&y))" }
129 timeout { fail "(timeout) print value of (0 && (x&&y))" }
134 send_gdb "print (0 && (x||y))\n"
136 -re ".$decimal = $false\r\n$gdb_prompt $" {
137 pass "print value of (0 && (x||y))"
139 -re ".*$gdb_prompt $" { fail "print value of (0 && (x||y))" }
140 timeout { fail "(timeout) print value of (0 && (x||y))" }
145 send_gdb "print (0 && (x&y))\n"
147 -re ".$decimal = $false\r\n$gdb_prompt $" {
148 pass "print value of (0 && (x&y))"
150 -re ".*$gdb_prompt $" { fail "print value of (0 && (x&y))" }
151 timeout { fail "(timeout) print value of (0 && (x&y))" }
155 send_gdb "print (0 && (x|y))\n"
157 -re ".$decimal = $false\r\n$gdb_prompt $" {
158 pass "print value of (0 && (x|y))"
160 -re ".*$gdb_prompt $" { fail "print value of (0 && (x|y))" }
161 timeout { fail "(timeout) print value of (0 && (x|y))" }
165 send_gdb "print (0 && (x^y))\n"
167 -re ".$decimal = $false\r\n$gdb_prompt $" {
168 pass "print value of (0 && (x^y))"
170 -re ".*$gdb_prompt $" { fail "print value of (0 && (x^y))" }
171 timeout { fail "(timeout) print value of (0 && (x^y))" }
176 send_gdb "print (0 && (x < y))\n"
178 -re ".$decimal = $false\r\n$gdb_prompt $" {
179 pass "print value of (0 && (x < y))"
181 -re ".*$gdb_prompt $" { fail "print value of (0 && (x < y))" }
182 timeout { fail "(timeout) print value of (0 && (x < y))" }
186 send_gdb "print (0 && (x <= y))\n"
188 -re ".$decimal = $false\r\n$gdb_prompt $" {
189 pass "print value of (0 && (x <= y))"
191 -re ".*$gdb_prompt $" { fail "print value of (0 && (x <= y))" }
192 timeout { fail "(timeout) print value of (0 && (x <= y))" }
197 send_gdb "print (0 && (x>y))\n"
199 -re ".$decimal = $false\r\n$gdb_prompt $" {
200 pass "print value of (0 && (x>y))"
202 -re ".*$gdb_prompt $" { fail "print value of (0 && (x>y))" }
203 timeout { fail "(timeout) print value of (0 && (x>y))" }
207 send_gdb "print (0 && (x>=y))\n"
209 -re ".$decimal = $false\r\n$gdb_prompt $" {
210 pass "print value of (0 && (x>=y))"
212 -re ".*$gdb_prompt $" { fail "print value of (0 && (x>=y))" }
213 timeout { fail "(timeout) print value of (0 && (x>=y))" }
218 send_gdb "print (0 && (x==y))\n"
220 -re ".$decimal = $false\r\n$gdb_prompt $" {
221 pass "print value of (0 && (x==y))"
223 -re ".*$gdb_prompt $" { fail "print value of (0 && (x==y))" }
224 timeout { fail "(timeout) print value of (0 && (x==y))" }
228 send_gdb "print (0 && (x!=y))\n"
230 -re ".$decimal = $false\r\n$gdb_prompt $" {
231 pass "print value of (0 && (x!=y))"
233 -re ".*$gdb_prompt $" { fail "print value of (0 && (x!=y))" }
234 timeout { fail "(timeout) print value of (0 && (x!=y))" }
238 send_gdb "print (0 && (x<<31))\n"
240 -re ".$decimal = $false\r\n$gdb_prompt $" {
241 pass "print value of (0 && (x<<31))"
243 -re ".*$gdb_prompt $" { fail "print value of (0 && (x<<31))" }
244 timeout { fail "(timeout) print value of (0 && (x<<31))" }
248 send_gdb "print (0 && (x>>31))\n"
250 -re ".$decimal = $false\r\n$gdb_prompt $" {
251 pass "print value of (0 && (x>>31))"
253 -re ".*$gdb_prompt $" { fail "print value of (0 && (x>>31))" }
254 timeout { fail "(timeout) print value of (0 && (x>>31))" }
259 send_gdb "print (0 && (!x))\n"
261 -re ".$decimal = $false\r\n$gdb_prompt $" {
262 pass "print value of (0 && (!x))"
264 -re ".*$gdb_prompt $" { fail "print value of (0 && (!x))" }
265 timeout { fail "(timeout) print value of (0 && (!x))" }
269 send_gdb "print (0 && (~x))\n"
271 -re ".$decimal = $false\r\n$gdb_prompt $" {
272 pass "print value of (0 && (~x))"
274 -re ".*$gdb_prompt $" { fail "print value of (0 && (~x))" }
275 timeout { fail "(timeout) print value of (0 && (~x))" }
278 send_gdb "print (0 && (-x))\n"
280 -re ".$decimal = $false\r\n$gdb_prompt $" {
281 pass "print value of (0 && (-x))"
283 -re ".*$gdb_prompt $" { fail "print value of (0 && (-x))" }
284 timeout { fail "(timeout) print value of (0 && (-x))" }
288 send_gdb "print (0 && (x++))\n"
290 -re ".$decimal = $false\r\n$gdb_prompt $" {
291 pass "print value of (0 && (x++))"
293 -re ".*$gdb_prompt $" { fail "print value of (0 && (x++))" }
294 timeout { fail "(timeout) print value of (0 && (x++))" }
298 send_gdb "print (0 && (++x))\n"
300 -re ".$decimal = $false\r\n$gdb_prompt $" {
301 pass "print value of (0 && (++x))"
303 -re ".*$gdb_prompt $" { fail "print value of (0 && (++x))" }
304 timeout { fail "(timeout) print value of (0 && (++x))" }
308 send_gdb "print (0 && (x--))\n"
310 -re ".$decimal = $false\r\n$gdb_prompt $" {
311 pass "print value of (0 && (x--))"
313 -re ".*$gdb_prompt $" { fail "print value of (0 && (x--))" }
314 timeout { fail "(timeout) print value of (0 && (x--))" }
318 send_gdb "print (0 && (--x))\n"
320 -re ".$decimal = $false\r\n$gdb_prompt $" {
321 pass "print value of (0 && (--x))"
323 -re ".*$gdb_prompt $" { fail "print value of (0 && (--x))" }
324 timeout { fail "(timeout) print value of (0 && (--x))" }
327 send_gdb "print (0 && (x+=7))\n"
329 -re ".$decimal = $false\r\n$gdb_prompt $" {
330 pass "print value of (0 && (x+=7))"
332 -re ".*$gdb_prompt $" { fail "print value of (0 && (x+=7))" }
333 timeout { fail "(timeout) print value of (0 && (x+=7))" }
336 send_gdb "print (0 && (x=y))\n"
338 -re ".$decimal = $false\r\n$gdb_prompt $" {
339 pass "print value of (0 && (x=y))"
341 -re ".*$gdb_prompt $" { fail "print value of (0 && (x=y))" }
342 timeout { fail "(timeout) print value of (0 && (x=y))" }