OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gdb/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.cp/] [ambiguous.exp] - Blame information for rev 25

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 25 jlechner
# Copyright 1998, 1999, 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
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 3 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, see .
15
 
16
# This file is part of the gdb testsuite
17
 
18
# tests relating to ambiguous class members
19
# Written by Satish Pai  1997-07-28
20
 
21
# This file is part of the gdb testsuite
22
 
23
if $tracelevel then {
24
        strace $tracelevel
25
        }
26
 
27
#
28
# test running programs
29
#
30
 
31
set prms_id 0
32
set bug_id 0
33
 
34
if { [skip_cplus_tests] } { continue }
35
 
36
set testfile "ambiguous"
37
set srcfile ${testfile}.cc
38
set binfile ${objdir}/${subdir}/${testfile}
39
 
40
if [get_compiler_info ${binfile} "c++"] {
41
    return -1;
42
}
43
 
44
if { [test_compiler_info gcc-*] } then { continue }
45
 
46
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
47
     untested ambiguous.exp
48
     return -1
49
}
50
 
51
 
52
gdb_exit
53
gdb_start
54
gdb_reinitialize_dir $srcdir/$subdir
55
gdb_load ${binfile}
56
 
57
 
58
#
59
# set it up at a breakpoint so we can play with the variable values
60
#
61
if ![runto_main] then {
62
    perror "couldn't run to breakpoint"
63
    continue
64
}
65
 
66
send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
67
    send_gdb "cont\n"
68
    gdb_expect {
69
        -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
70
            send_gdb "up\n"
71
            gdb_expect {
72
                -re ".*$gdb_prompt $" { pass "up from marker1" }
73
                timeout { fail "up from marker1" }
74
            }
75
        }
76
        -re "$gdb_prompt $" { fail "continue to marker1"  }
77
        timeout { fail "(timeout) continue to marker1"  }
78
    }
79
 
80
# print out various class objects' members.  The values aren't
81
# important, just check that the warning is emitted at the
82
# right times.
83
 
84
# X is derived from A1 and A2; both A1 and A2 have a member 'x'
85
send_gdb "print x.x\n"
86
gdb_expect {
87
   -re "warning: x ambiguous; using X::A2::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
88
       pass "print x.x"
89
   }
90
   -re "warning: x ambiguous; using X::A1::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
91
       pass "print x.x"
92
   }
93
   -re ".*$gdb_prompt $" { fail "print x.x" }
94
   timeout { fail "(timeout) print x.x" }
95
}
96
 
97
 
98
# N is derived from A1 and A2, but not immediately -- two steps
99
# up in the hierarchy. Both A1 and A2 have a member 'x'.
100
send_gdb "print n.x\n"
101
gdb_expect {
102
   -re "warning: x ambiguous; using N::M::A2::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
103
       pass "print n.x"
104
   }
105
   -re "warning: x ambiguous; using N::L::A1::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
106
       pass "print n.x"
107
   }
108
   -re ".*$gdb_prompt $" { fail "print n.x" }
109
   timeout { fail "(timeout) print n.x" }
110
}
111
 
112
# J is derived from A1 twice.  A1 has a member x.
113
send_gdb "print j.x\n"
114
gdb_expect {
115
   -re "warning: x ambiguous; using J::L::A1::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
116
       pass "print j.x"
117
   }
118
   -re "warning: x ambiguous; using J::K::A1::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
119
       pass "print j.x"
120
   }
121
   -re ".*$gdb_prompt $" { fail "print j.x" }
122
   timeout { fail "(timeout) print j.x" }
123
}
124
 
125
# JV is derived from A1 but A1 is a virtual base. Should not
126
# report an ambiguity in this case.
127
send_gdb "print jv.x\n"
128
gdb_expect {
129
   -re "warning: x ambiguous.*Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
130
       fail "print jv.x (ambiguity reported)"
131
   }
132
   -re "\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" { pass "print jv.x" }
133
   -re ".*$gdb_prompt $" { fail "print jv.x (??)" }
134
   timeout { fail "(timeout) print jv.x" }
135
}
136
 
137
# JVA1 is derived from A1; A1 occurs as a virtual base in two
138
# ancestors, and as a non-virtual immediate base. Ambiguity must
139
# be reported.
140
send_gdb "print jva1.x\n"
141
gdb_expect {
142
   -re "warning: x ambiguous; using JVA1::A1::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
143
       pass "print jva1.x"
144
   }
145
   -re "warning: x ambiguous; using JVA1::KV::A1::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
146
       pass "print jva1.x"
147
   }
148
   -re ".*$gdb_prompt $" { fail "print jva1.x" }
149
   timeout { fail "(timeout) print jva1.x" }
150
}
151
 
152
# JVA2 is derived from A1 & A2; A1 occurs as a virtual base in two
153
# ancestors, and A2 is a non-virtual immediate base. Ambiguity must
154
# be reported as A1 and A2 both have a member 'x'.
155
send_gdb "print jva2.x\n"
156
gdb_expect {
157
   -re "warning: x ambiguous; using JVA2::A2::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
158
       pass "print jva2.x"
159
   }
160
   -re "warning: x ambiguous; using JVA2::KV::A1::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
161
       pass "print jva2.x"
162
   }
163
   -re ".*$gdb_prompt $" { fail "print jva2.x" }
164
   timeout { fail "(timeout) print jva2.x" }
165
}
166
 
167
# JVA1V is derived from A1; A1 occurs as a virtual base in two
168
# ancestors, and also as a virtual immediate base. Ambiguity must
169
# not be reported.
170
send_gdb "print jva1v.x\n"
171
gdb_expect {
172
   -re "warning: x ambiguous.*Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
173
       fail "print jva1v.x (ambiguity reported)"
174
   }
175
   -re "\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" { pass "print jva1v.x" }
176
   -re ".*$gdb_prompt $" { fail "print jva1v.x (??)" }
177
   timeout { fail "(timeout) print jva1v.x" }
178
}
179
 
180
# Now check for ambiguous bases.
181
 
182
# J is derived from A1 twice; report ambiguity if a J is
183
# cast to an A1.
184
send_gdb "print (A1)j\n"
185
gdb_expect {
186
   -re "warning: A1 ambiguous; using J::L::A1. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \{x = \[-\]*\[0-9\]*, y = \[-\]*\[0-9\]*\}\r\n$gdb_prompt $" {
187
       pass "print (A1)j"
188
   }
189
   -re "warning: A1 ambiguous; using J::K::A1. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \{x = \[-\]*\[0-9\]*, y = \[-\]*\[0-9\]*\}\r\n$gdb_prompt $" {
190
       pass "print (A1)j"
191
   }
192
   -re ".*$gdb_prompt $" { fail "print (A1)j" }
193
   timeout { fail "(timeout) print (A1)j" }
194
}
195
 
196
# JV is derived from A1 twice, but A1 is a virtual base; should
197
# not report ambiguity when a JV is cast to an A1.
198
send_gdb "print (A1)jv\n"
199
gdb_expect {
200
   -re "warning: A1 ambiguous.*Use a cast to disambiguate.\r\n\\$\[0-9\]* = \{x = \[-\]*\[0-9\]*, y = \[-\]*\[0-9\]*\}\r\n$gdb_prompt $" {
201
       fail "print (A1)jv (ambiguity reported)"
202
   }
203
   -re "\\$\[0-9\]* = \{x = \[-\]*\[0-9\]*, y = \[-\]*\[0-9\]*\}\r\n$gdb_prompt $" { pass "print (A1)jv" }
204
   -re ".*$gdb_prompt $" { fail "print (A1)jv (??)" }
205
   timeout { fail "(timeout) print (A1)jv" }
206
}
207
 
208
# JVA1 is derived from A1; A1 is a virtual base and also a
209
# non-virtual base.  Must report ambiguity if a JVA1 is cast to an A1.
210
send_gdb "print (A1)jva1\n"
211
gdb_expect {
212
   -re "warning: A1 ambiguous; using JVA1::A1. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \{x = \[-\]*\[0-9\]*, y = \[-\]*\[0-9\]*\}\r\n$gdb_prompt $" {
213
       pass "print (A1)jva1"
214
   }
215
   -re "warning: A1 ambiguous; using JVA1::KV::A1. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \{x = \[-\]*\[0-9\]*, y = \[-\]*\[0-9\]*\}\r\n$gdb_prompt $" {
216
       pass "print (A1)jva1"
217
   }
218
   -re ".*$gdb_prompt $" { fail "print (A1)jva1" }
219
   timeout { fail "(timeout) print (A1)jva1" }
220
}
221
 
222
# JVA1V is derived from A1; A1 is a virtual base indirectly
223
# and also directly; must not report ambiguity when a JVA1V is cast to an A1.
224
send_gdb "print (A1)jva1v\n"
225
gdb_expect {
226
   -re "warning: A1 ambiguous.*Use a cast to disambiguate.\r\n\\$\[0-9\]* = \{x = \[-\]*\[0-9\]*, y = \[-\]*\[0-9\]*\}\r\n$gdb_prompt $" {
227
       fail "print (A1)jva1v (ambiguity reported)"
228
   }
229
   -re "\\$\[0-9\]* = \{x = \[-\]*\[0-9\]*, y = \[-\]*\[0-9\]*\}\r\n$gdb_prompt $" { pass "print (A1)jva1v"
230
   }
231
   -re ".*$gdb_prompt $" { fail "print (A1)jva1v (??)" }
232
   timeout { fail "(timeout) print (A1)jva1v" }
233
}
234
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.