Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.ada / array_of_variant.exp
CommitLineData
88b9d363 1# Copyright 2020-2022 Free Software Foundation, Inc.
7ff5b937
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
16load_lib "ada.exp"
17
18if { [skip_ada_tests] } { return -1 }
19
20standard_ada_testfile p
21
7e292f1a
TV
22if [get_compiler_info] {
23 return -1
24}
25set old_gcc [expr [test_compiler_info {gcc-[0-7]-*}]]
26
27proc gdb_test_with_xfail { cmd re re_xfail msg } {
28 global scenario old_gcc
29 set have_xfail [expr $old_gcc && [string equal "$scenario" "minimal"]]
30
31 gdb_test_multiple $cmd $msg {
32 -re -wrap $re {
33 pass $gdb_test_name
34 }
35 -re -wrap $re_xfail {
36 if { $have_xfail } {
37 # gcc/101633
38 setup_xfail *-*-*
39 }
40 fail $gdb_test_name
41 }
42 }
43}
44
7ff5b937
TT
45foreach_with_prefix scenario {all minimal} {
46 set flags [list debug additional_flags=-fgnat-encodings=$scenario]
47
48 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable $flags] != ""} {
49 return -1
50 }
51
52 clean_restart ${testfile}
53
54 set bp_location [gdb_get_line_number "START" ${testdir}/p.adb]
55 runto "p.adb:$bp_location"
56
57 set v1 "(tag => object, values => (2, 2, 2, 2, 2))"
7e292f1a 58 set v1_xfail "(tag => object, values => ())"
7ff5b937
TT
59 set v2 "(tag => unused)"
60
7e292f1a
TV
61 set re [string_to_regexp " = ($v1, $v2)"]
62 set re_xfail [string_to_regexp " = ($v1_xfail, $v2)"]
63 gdb_test_with_xfail "print objects" $re $re_xfail "print entire array"
64
65 set re [string_to_regexp " = $v1"]
66 set re_xfail [string_to_regexp " = $v1_xfail"]
67 gdb_test_with_xfail "print objects(1)" $re $re_xfail \
7ff5b937 68 "print first array element"
7e292f1a
TV
69
70 set re [string_to_regexp " = ($v1)"]
71 set re_xfail [string_to_regexp " = ($v1_xfail)"]
72 gdb_test_with_xfail "print objects(1 .. 1)" $re $re_xfail \
7ff5b937 73 "print first array slice"
7e292f1a 74
7ff5b937
TT
75 gdb_test "print objects(2)" \
76 [string_to_regexp " = $v2"] \
77 "print second array element"
78 gdb_test "print objects(2 .. 2)" \
79 [string_to_regexp " = (2 => $v2)"] \
80 "print second array slice"
81}
This page took 0.12628 seconds and 4 git commands to generate.