* ax-gdb.c (gen_expr): Add UNOP_PLUS case.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / userdef.exp
CommitLineData
d4f3574e 1# Tests of overloaded operators resolution.
6e19e2bf 2# Copyright 1998, 1999, 2002, 2004 Free Software Foundation, Inc.
c906108c
SS
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 2 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, write to the Free Software
16# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
c906108c
SS
18# written by Elena Zannoni (ezannoni@cygnus.com)
19#
c906108c
SS
20# source file "userdef.cc"
21#
22
c906108c
SS
23if $tracelevel then {
24 strace $tracelevel
25}
26
d4f3574e 27if { [skip_cplus_tests] } { continue }
c906108c
SS
28
29set testfile "userdef"
30set srcfile ${testfile}.cc
31set binfile ${objdir}/${subdir}/${testfile}
32
33if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
34 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
35}
36
37
38gdb_exit
39gdb_start
40gdb_reinitialize_dir $srcdir/$subdir
41gdb_load ${binfile}
42
43
44if ![runto_main] then {
45 perror "couldn't run to breakpoint"
46 continue
47}
48
49send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
50 send_gdb "cont\n"
51 gdb_expect {
5178b9d6 52 -re "Break.* marker1(\\(\\)|) \\(\\) at .*:$decimal.*$gdb_prompt $" {
c906108c
SS
53 send_gdb "up\n"
54 gdb_expect {
55 -re ".*$gdb_prompt $" { pass "up from marker1" }
56 timeout { fail "up from marker1" }
57 }
58 }
59 -re "$gdb_prompt $" { fail "continue to marker1" }
60 timeout { fail "(timeout) continue to marker1" }
61 }
62
63
fb8acdcc
DJ
64gdb_test "print one + two" "\\\$\[0-9\]* = {x = 6, y = 8}"
65
5624293a
JB
66# If GDB fails to restore the selected frame properly after the
67# inferior function call above (see GDB PR 1155 for an explanation of
68# why this might happen), all the subsequent tests will fail. We
69# should detect report that failure, but let the marker call finish so
70# that the rest of the tests can run undisturbed.
71gdb_test_multiple "frame" "re-selected 'main' frame after inferior call" {
72 -re "#0 marker1.*$gdb_prompt $" {
73 setup_kfail "gdb/1155" s390-*-linux-gnu
74 fail "re-selected 'main' frame after inferior call"
93201743 75 gdb_test "finish" ".*main.*at .*userdef.cc:.*// marker1-returns-here.*" \
5624293a
JB
76 "finish call to marker1"
77 }
78 -re "#1 ($hex in )?main.*$gdb_prompt $" {
79 pass "re-selected 'main' frame after inferior call"
80 }
81}
82
fb8acdcc
DJ
83gdb_test "print one - two" "\\\$\[0-9\]* = {x = -2, y = -2}"
84
85gdb_test "print one * two" "\\\$\[0-9\]* = {x = 8, y = 15}"
86
87gdb_test "print one / two" "\\\$\[0-9\]* = {x = 0, y = 0}"
88
89gdb_test "print one % two" "\\\$\[0-9\]* = {x = 2, y = 3}"
90
91gdb_test "print one && two" "\\\$\[0-9\]* = 1\[\r\n\]"
92
93gdb_test "print one || two" "\\\$\[0-9\]* = 1\[\r\n\]"
94
95gdb_test "print one & two" "\\\$\[0-9\]* = {x = 0, y = 1}"
96
97gdb_test "print one | two" "\\\$\[0-9\]* = {x = 6, y = 7}"
98
99gdb_test "print one ^ two" "\\\$\[0-9\]* = {x = 6, y = 6}"
100
101gdb_test "print one < two" "\\\$\[0-9\]* = 1\[\r\n\]"
102
103gdb_test "print one <= two" "\\\$\[0-9\]* = 1\[\r\n\]"
104
105gdb_test "print one > two" "\\\$\[0-9\]* = 0\[\r\n\]"
106
107gdb_test "print one >= two" "\\\$\[0-9\]* = 0\[\r\n\]"
108
109gdb_test "print one == two" "\\\$\[0-9\]* = 0\[\r\n\]"
110
111gdb_test "print one != two" "\\\$\[0-9\]* = 1\[\r\n\]"
112
113# Can't really check the output of this one without knowing
114# target integer width. Make sure we don't try to call
115# the iostreams operator instead, though.
116gdb_test "print one << 31" "\\\$\[0-9\]* = {x = -?\[0-9\]*, y = -?\[0-9\]*}"
117
118# Should be fine even on < 32-bit targets.
119gdb_test "print one >> 31" "\\\$\[0-9\]* = {x = 0, y = 0}"
120
121gdb_test "print !one" "\\\$\[0-9\]* = 0\[\r\n\]"
122
123# Assumes 2's complement. So does everything...
36e9969c
NS
124gdb_test "print +one" "\\\$\[0-9\]* = {x = 2, y = 3}"
125
fb8acdcc
DJ
126gdb_test "print ~one" "\\\$\[0-9\]* = {x = -3, y = -4}"
127
128gdb_test "print -one" "\\\$\[0-9\]* = {x = -2, y = -3}"
129
130gdb_test "print one++" "\\\$\[0-9\]* = {x = 2, y = 4}"
131
132gdb_test "print ++one" "\\\$\[0-9\]* = {x = 3, y = 4}"
133
134gdb_test "print one--" "\\\$\[0-9\]* = {x = 3, y = 3}"
135
136gdb_test "print --one" "\\\$\[0-9\]* = {x = 2, y = 3}"
137
138gdb_test "print one += 7" "\\\$\[0-9\]* = {x = 9, y = 10}"
139
140gdb_test "print two = one" "\\\$\[0-9\]* = {x = 9, y = 10}"
c906108c 141
13b57657 142# Check that GDB tolerates whitespace in operator names.
36e9969c
NS
143gdb_test "break A2::'operator+'" ".*Breakpoint $decimal at.*"
144gdb_test "break A2::'operator +'" ".*Breakpoint $decimal at.*"
13b57657 145
c906108c
SS
146gdb_exit
147return 0
This page took 0.978506 seconds and 4 git commands to generate.