Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.ada / enum_idx_packed.exp
CommitLineData
88b9d363 1# Copyright 2012-2022 Free Software Foundation, Inc.
99b1c762
JB
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 <http://www.gnu.org/licenses/>.
15
16load_lib "ada.exp"
17
18if { [skip_ada_tests] } { return -1 }
19
8223e12c 20standard_ada_testfile foo
99b1c762 21
b72795a8
TT
22foreach_with_prefix scenario {all minimal} {
23 set flags [list debug additional_flags=-fgnat-encodings=$scenario]
99b1c762 24
b72795a8
TT
25 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable $flags] != ""} {
26 return -1
27 }
99b1c762 28
b72795a8 29 clean_restart ${testfile}
99b1c762 30
891615f0
TV
31 # GNAT 9 and 10 are known to fail.
32 if {$scenario == "minimal" && ([test_compiler_info {gcc-9-*}] \
33 || [test_compiler_info {gcc-10-*}])} {
b72795a8
TT
34 set old_compiler 1
35 } else {
36 set old_compiler 0
37 }
a7400e44 38
b72795a8
TT
39 set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb]
40 runto "foo.adb:$bp_location"
99b1c762 41
b72795a8
TT
42 gdb_test "ptype full" \
43 "type = array \\(black \\.\\. white\\) of boolean <packed: 1-bit elements>"
99b1c762 44
b72795a8 45 gdb_test "print full" " = \\(false, true, false, true, false\\)"
a7400e44 46
b72795a8 47 gdb_test "print full'first" " = black"
a7400e44 48
b72795a8
TT
49 gdb_test "ptype primary" \
50 "type = array \\(red \\.\\. blue\\) of boolean <packed: 1-bit elements>"
a7400e44 51
b72795a8 52 gdb_test "print primary" " = \\(red => false, true, false\\)"
a7400e44 53
b72795a8 54 gdb_test "print primary'first" " = red"
a7400e44 55
b72795a8
TT
56 gdb_test "ptype cold" \
57 "type = array \\(green \\.\\. blue\\) of boolean <packed: 1-bit elements>"
a7400e44 58
b72795a8 59 gdb_test "print cold" " = \\(green => false, true\\)"
a7400e44 60
b72795a8 61 gdb_test "print cold'first" " = green"
a7400e44 62
b72795a8
TT
63 # Note the bounds values are still not correctly displayed. So we get
64 # the enum equivalent of "1 .. 0" (empty range) as the array ranges.
65 # Accept that for now.
66 # GNAT >= 11.0 has the needed fix here.
67 if {$old_compiler} {
68 setup_kfail "minimal encodings" *-*-*
69 }
70 gdb_test "ptype small" \
71 "array \\(red \\.\\. green\\) of boolean <packed: 1-bit elements>"
a7400e44 72
b72795a8
TT
73 if {$old_compiler} {
74 setup_kfail "minimal encodings" *-*-*
75 }
76 gdb_test "print small" " = \\(red => false, true\\)"
a7400e44 77
b72795a8
TT
78 if {$old_compiler} {
79 setup_kfail "minimal encodings" *-*-*
80 }
81 gdb_test "print small'first" " = red"
a7400e44 82
b72795a8
TT
83 if {$old_compiler} {
84 setup_kfail "minimal encodings" *-*-*
85 }
86 gdb_test "ptype multi" \
87 "array \\(red \\.\\. green, low .. medium\\) of boolean <packed: 1-bit elements>"
a7400e44 88
b72795a8
TT
89 if {$old_compiler} {
90 setup_kfail "minimal encodings" *-*-*
a7400e44 91 }
b72795a8
TT
92 gdb_test "print multi" \
93 " = \\(red => \\(low => true, false\\), \\(low => true, false\\)\\)"
a7400e44 94
b72795a8
TT
95 if {$old_compiler} {
96 setup_kfail "minimal encodings" *-*-*
97 }
98 gdb_test "print multi'first" " = red"
99
100 set base "\\(true, false, true, false, true, false, true, false, true, false\\)"
101 set matrix "\\("
102 foreach x {1 2 3 4 5 6 7} {
103 if {$x > 1} {
104 append matrix ", "
105 }
106 append matrix $base
107 }
108 append matrix "\\)"
109
110 if {$old_compiler} {
111 setup_kfail "minimal encodings" *-*-*
112 }
113 gdb_test "print multi_multi" " = \\($matrix, $matrix\\)"
114 if {$old_compiler} {
115 setup_kfail "minimal encodings" *-*-*
116 }
117 gdb_test "print multi_multi(1,3)" " = $base"
118 if {$old_compiler} {
119 setup_kfail "minimal encodings" *-*-*
120 }
121 gdb_test "print multi_multi(2)" " = $matrix"
10f6a3ad
TT
122
123 gdb_test "print multi_access.all" \
124 " = \\(\\(8, 13, 21, 34, 55\\), \\(1, 1, 2, 3, 5\\)\\)"
2869ac4b
TT
125
126 gdb_test "print confused_array(red, green)" " = 2"
127 gdb_test "print confused_array(green, red)" " = 6"
b72795a8 128}
This page took 1.250529 seconds and 4 git commands to generate.