Commit | Line | Data |
---|---|---|
3666a048 | 1 | # Copyright 2019-2021 Free Software Foundation, Inc. |
6c71eb7d TT |
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 | ||
16 | # Test ptype of an unchecked union. | |
17 | ||
18 | load_lib "ada.exp" | |
19 | ||
7a82e903 PA |
20 | if { [skip_ada_tests] } { return -1 } |
21 | ||
6c71eb7d TT |
22 | standard_ada_testfile unchecked_union |
23 | ||
6c71eb7d TT |
24 | proc multi_line_string {str} { |
25 | set result {} | |
26 | foreach line [split $str \n] { | |
27 | lappend result [string_to_regexp $line] | |
28 | } | |
29 | return [eval multi_line $result] | |
30 | } | |
31 | ||
32 | set inner_string { case ? is | |
33 | when ? => | |
34 | small: range 0 .. 255; | |
35 | when ? => | |
36 | large: range 255 .. 510; | |
37 | end case; | |
38 | } | |
39 | set inner_full "type = record (?) is\n${inner_string}end record" | |
40 | ||
41 | set pair_string { case ? is | |
42 | when ? => | |
43 | field_one: range 0 .. 255; | |
44 | when ? => | |
45 | field_two: range 255 .. 510; | |
46 | end case; | |
47 | } | |
48 | set pair_full "type = record\n${inner_string}${pair_string}end record" | |
49 | ||
adfb9815 TT |
50 | foreach_with_prefix scenario {none all minimal} { |
51 | set flags {debug} | |
52 | if {$scenario != "none"} { | |
53 | lappend flags additional_flags=-fgnat-encodings=$scenario | |
54 | } | |
55 | ||
56 | if {[gdb_compile_ada "${srcfile}" "${binfile}" executable $flags] != ""} { | |
57 | return -1 | |
58 | } | |
59 | ||
60 | clean_restart ${testfile} | |
61 | ||
62 | set bp_location [gdb_get_line_number "BREAK" ${testdir}/unchecked_union.adb] | |
63 | runto "unchecked_union.adb:$bp_location" | |
64 | ||
65 | gdb_test "ptype Pair" [multi_line_string $pair_full] | |
66 | gdb_test "ptype Inner" [multi_line_string $inner_full] | |
67 | } |