1# Copyright 1998, 1999, 2007, 2008, 2009, 2010, 2011
2# Free Software Foundation, Inc.
3
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.
8#
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.
13#
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/>.
16
17# This file was written by Elena Zannoni (ezannoni@cygnus.com)
18
19# This file is part of the gdb testsuite
20
21#
22# tests to cover evaluate_subexp_standard with the EVAL_SKIP flag set.
23# this happens for instance when there is short circuit evaluation in the && and ||
24# operators, or in the non returned part of a (x ? y: z) expression.
25# the part that is not evaluated is parsed and evaluated anyway, but with
26# the EVAL_SKIP flag set
27#
28# source file "int-type.c"
29#
30
31
32if $tracelevel then {
33        strace $tracelevel
34}
35
36# Check to see if we have an executable to test.  If not, then either we
37# haven't tried to compile one, or the compilation failed for some reason.
38# In either case, just notify the user and skip the tests in this file.
39
40set testfile "int-type"
41set srcfile ${testfile}.c
42set binfile ${objdir}/${subdir}/${testfile}
43
44if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
45     untested eval-skip.exp
46     return -1
47    }
48
49if [get_compiler_info $binfile] {
50    return -1
51}
52
53gdb_exit
54gdb_start
55gdb_reinitialize_dir $srcdir/$subdir
56gdb_load ${binfile}
57
58
59if ![runto_main] then {
60    perror "couldn't run to breakpoint"
61    continue
62}
63
64gdb_test_no_output "set variable x=14" "set variable x=14"
65gdb_test_no_output "set variable y=2" "set variable y=2"
66gdb_test_no_output "set variable z=2" "set variable z=2"
67gdb_test_no_output "set variable w=3" "set variable w=3"
68
69gdb_test "print (0 && (x+y))" ".$decimal = $false" \
70    "print value of (0 && (x+y))"
71
72gdb_test "print (0 && (x-y))" ".$decimal = $false" \
73    "print value of (0 && (x-y))"
74
75gdb_test "print (0 && (x*y))" ".$decimal = $false" \
76    "print value of (0 && (x*y))"
77
78gdb_test "print (0 && (x/y))" ".$decimal = $false" \
79    "print value of (0 && (x/y))"
80
81gdb_test "print (0 && (x%y))" ".$decimal = $false" \
82    "print value of (0 && (x%y))"
83
84gdb_test "print (0 && (x&&y))" ".$decimal = $false" \
85    "print value of (0 && (x&&y))"
86
87gdb_test "print (0 && (x||y))" ".$decimal = $false" \
88    "print value of (0 && (x||y))"
89
90gdb_test "print (0 && (x&y))" ".$decimal = $false" \
91    "print value of (0 && (x&y))"
92
93gdb_test "print (0 && (x|y))" ".$decimal = $false" \
94    "print value of (0 && (x|y))"
95
96gdb_test "print (0 && (x^y))" ".$decimal = $false" \
97    "print value of (0 && (x^y))"
98
99gdb_test "print (0 && (x < y))" ".$decimal = $false" \
100    "print value of (0 && (x < y))"
101
102gdb_test "print (0 && (x <= y))" ".$decimal = $false" \
103    "print value of (0 && (x <= y))"
104
105gdb_test "print (0 && (x>y))" ".$decimal = $false" \
106    "print value of (0 && (x>y))"
107
108gdb_test "print (0 && (x>=y))" ".$decimal = $false" \
109    "print value of (0 && (x>=y))"
110
111gdb_test "print (0 && (x==y))" ".$decimal = $false" \
112    "print value of (0 && (x==y))"
113
114gdb_test "print (0 && (x!=y))" ".$decimal = $false" \
115    "print value of (0 && (x!=y))"
116
117gdb_test "print (0 && (x<<31))" ".$decimal = $false" \
118    "print value of (0 && (x<<31))"
119
120gdb_test "print (0 && (x>>31))" ".$decimal = $false" \
121    "print value of (0 && (x>>31))"
122
123gdb_test "print (0 && (!x))" ".$decimal = $false" \
124    "print value of (0 && (!x))"
125
126gdb_test "print (0 && (~x))" ".$decimal = $false" \
127    "print value of (0 && (~x))"
128
129gdb_test "print (0 && (-x))" ".$decimal = $false" \
130    "print value of (0 && (-x))"
131
132gdb_test "print (0 && (x++))" ".$decimal = $false" \
133    "print value of (0 && (x++))"
134
135gdb_test "print (0 && (++x))" ".$decimal = $false" \
136    "print value of (0 && (++x))"
137
138gdb_test "print (0 && (x--))" ".$decimal = $false" \
139    "print value of (0 && (x--))"
140
141gdb_test "print (0 && (--x))" ".$decimal = $false" \
142    "print value of (0 && (--x))"
143
144gdb_test "print (0 && (x+=7))" ".$decimal = $false" \
145    "print value of (0 && (x+=7))"
146
147gdb_test "print (0 && (x=y))" ".$decimal = $false" \
148    "print value of (0 && (x=y))"
149
150
151gdb_exit
152return 0
153
154
155
156
157
158
159
160