Update copyright year range in header of all files managed by GDB
[binutils-gdb.git] / gdb / testsuite / gdb.ada / enum_idx_packed.exp
blob4432c7a3fdf7ea21985b5d746c5030cab347d647
1 # Copyright 2012-2023 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 load_lib "ada.exp"
18 if { [skip_ada_tests] } { return -1 }
20 standard_ada_testfile foo
22 foreach_with_prefix scenario {all minimal} {
23     set flags [list debug additional_flags=-fgnat-encodings=$scenario]
25     if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
26         return -1
27     }
29     clean_restart ${testfile}-${scenario}
31     # GNAT 9 and 10 are known to fail.
32     if {$scenario == "minimal" && ([test_compiler_info {gcc-9-*}] \
33                                        || [test_compiler_info {gcc-10-*}])} {
34         set old_compiler 1
35     } else {
36         set old_compiler 0
37     }
39     set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb]
40     runto "foo.adb:$bp_location"
42     gdb_test "ptype full" \
43         "type = array \\(black \\.\\. white\\) of boolean <packed: 1-bit elements>"
45     gdb_test "print full" " = \\(false, true, false, true, false\\)"
47     gdb_test "print full'first" " = black"
49     gdb_test "ptype primary" \
50         "type = array \\(red \\.\\. blue\\) of boolean <packed: 1-bit elements>"
52     gdb_test "print primary" " = \\(red => false, true, false\\)"
54     gdb_test "print primary'first" " = red"
56     gdb_test "ptype cold" \
57         "type = array \\(green \\.\\. blue\\) of boolean <packed: 1-bit elements>"
59     gdb_test "print cold" " = \\(green => false, true\\)"
61     gdb_test "print cold'first" " = green"
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>"
73     if {$old_compiler} {
74         setup_kfail "minimal encodings" *-*-*
75     }
76     gdb_test "print small" " = \\(red => false, true\\)"
78     if {$old_compiler} {
79         setup_kfail "minimal encodings" *-*-*
80     }
81     gdb_test "print small'first" " = red"
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>"
89     if {$old_compiler} {
90         setup_kfail "minimal encodings" *-*-*
91     }
92     gdb_test "print multi" \
93         " = \\(red => \\(low => true, false\\), \\(low => true, false\\)\\)"
95     if {$old_compiler} {
96         setup_kfail "minimal encodings" *-*-*
97     }
98     gdb_test "print multi'first" " = red"
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 "\\)"
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"
123     gdb_test "print multi_access.all" \
124         " = \\(\\(8, 13, 21, 34, 55\\), \\(1, 1, 2, 3, 5\\)\\)"
126     gdb_test "print confused_array(red, green)" " = 2"
127     gdb_test "print confused_array(green, red)" " = 6"