]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.cp/empty-enum.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.cp / empty-enum.exp
CommitLineData
1d506c26 1# Copyright 2023-2024 Free Software Foundation, Inc.
85c7cb3c
AB
2# This program is free software; you can redistribute it and/or modify
3# it under the terms of the GNU General Public License as published by
4# the Free Software Foundation; either version 3 of the License, or
5# (at your option) any later version.
6#
7# This program is distributed in the hope that it will be useful,
8# but WITHOUT ANY WARRANTY; without even the implied warranty of
9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10# GNU General Public License for more details.
11#
12# You should have received a copy of the GNU General Public License
13# along with this program. If not, see <http://www.gnu.org/licenses/>.
14
15# Test how GDB displays empty enums. At one point an enum with no
16# enumeration values would be considered a flag enum, and, as a
17# consequence any value with that type would display like:
18#
19# (gdb) print enum_var
20# $1 = (unknown: 0x8)
21#
22# Which resulted in a lot of noise. Now GDB treats empty enums as a
23# non-flag enum, and should print them like this:
24#
25# (gdb) print enum_var
26# $1 = 8
27#
28# This test checks this behaviour.
29
30standard_testfile .cc
31
c67caa51
TV
32set opts {}
33lappend opts debug
34lappend opts additional_flags=-std=c++11
35
36if {[prepare_for_testing "failed to prepare" $testfile $srcfile $opts]} {
85c7cb3c
AB
37 return -1
38}
39
40if {![runto_main]} {
41 return -1
42}
43
44gdb_breakpoint "breakpt"
45gdb_continue_to_breakpoint "stop in breakpt"
46
47
48gdb_test "print arg1" " = 8"
49gdb_test "print arg2" " = 4"
50
c67caa51
TV
51
52# Xfail for missing DW_AT_type in DW_TAG_enumeration_type, gcc PR debug/16063.
53set have_xfail [expr [test_compiler_info gcc-*] && [gcc_major_version] < 5]
54
55gdb_test_multiple "ptype arg1" "" {
56 -re -wrap "type = enum enum1 : unsigned int \\{\\}" {
57 pass $gdb_test_name
58 }
59 -re -wrap "type = enum enum1 \\{\\}" {
60 if { $have_xfail } {
61 setup_xfail *-*-* gcc/16063
62 }
63 fail $gdb_test_name
64 }
65}
66
67gdb_test_multiple "ptype arg2" "" {
68 -re -wrap "type = enum class enum2 : unsigned char \\{\\}" {
69 pass $gdb_test_name
70 }
71 -re -wrap "type = enum class enum2 \\{\\}" {
72 if { $have_xfail } {
73 setup_xfail *-*-* gcc/16063
74 }
75 fail $gdb_test_name
76 }
77}