1 # Copyright
2014-2022 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 is part of the gdb testsuite
18 # Test expressions in which
variable names shadow tag names.
20 if {[skip_cplus_tests
]} { return }
22 standard_testfile var
-tag.cc var
-tag
-2.cc var
-tag
-3.cc var
-tag
-4.cc
24 if {[prepare_for_testing
"failed to prepare" $testfile \
25 [list $srcfile $srcfile2 $srcfile3 $srcfile4
] {debug c
++}]} {
29 proc do_global_tests
{lang
} {
30 set invalid_print
"Attempt to use a type name as an expression"
33 set opt_underlying
"(: unsigned (int|short|char) )?"
37 set ptypefmt
"type = (class|enum|union|struct) %s $opt_underlying{.*}"
39 with_test_prefix $lang
{
40 gdb_test_no_output
"set language $lang"
41 gdb_test
"ptype C" "type = class C {.*}"
42 gdb_test
"print E" "= a"
43 gdb_test
"ptype E" "type = enum E $opt_underlying{.*}"
44 gdb_test
"print S" "= {<No data fields>}"
45 gdb_test
"ptype S" "type = struct S {.*}"
46 gdb_test
"print U" "= {.*}"
47 gdb_test
"ptype U" "type = union U {.*}"
48 gdb_test
"print cc" "= {.*}"
49 gdb_test
"ptype cc" "type = class CC {.*}"
50 gdb_test
"print CC" [format $invalid_print "CC"]
51 gdb_test
"ptype CC" [format $ptypefmt "CC"]
52 gdb_test
"print ss" "= {<No data fields>}"
53 gdb_test
"ptype ss" "type = struct SS {.*}"
54 gdb_test
"print SS" [format $invalid_print "SS"]
55 gdb_test
"ptype SS" [format $ptypefmt "SS"]
56 gdb_test
"print ee" "= .*"
57 gdb_test
"ptype ee" "type = enum EE $opt_underlying{.*}"
58 gdb_test
"print EE" [format $invalid_print "EE"]
59 gdb_test
"ptype EE" [format $ptypefmt "EE"]
60 gdb_test
"print uu" "= {.*}"
61 gdb_test
"ptype uu" "type = union UU {.*}"
62 gdb_test
"print UU" [format $invalid_print "UU"]
63 gdb_test
"ptype UU" [format $ptypefmt "UU"]
65 # These tests exercise lookup of symbols using the
"quick fns" API.
66 # Each of them is in a separate CU as once its CU is expanded
,
67 # we
're no longer using the quick fns API.
68 gdb_test "print E2" "= a2"
69 gdb_test "ptype E2" "type = enum E2 $opt_underlying{.*}"
70 gdb_test "print S2" "= {<No data fields>}"
71 gdb_test "ptype S2" "type = struct S2 {.*}"
72 gdb_test "print U2" "= {.*}"
73 gdb_test "ptype U2" "type = union U2 {.*}"
77 # First test expressions when there is no context.
78 with_test_prefix "before start" {
83 # Run to main and test again.
85 perror "couldn't run to main
"
89 with_test_prefix
"in main" {
94 # Run to C
::f and test again.
96 gdb_continue_to_breakpoint
"continue to C::f"
97 with_test_prefix
"in C::f" {
102 # Another hard
-to
-guess
-the
-users
-intent bug...
103 # It would be really nice
if we could query the user
!
104 with_test_prefix
"global collision" {
105 gdb_test_no_output
"set language c++"
106 setup_kfail
"c++/16463" "*-*-*"
107 gdb_test
"print global" "= 3"
109 # ... with a simple workaround
:
110 gdb_test
"print ::global" "= 3"