Introduce and use foreach_gnat_encoding

gnat-llvm does not support the -fgnat-encodings flag.  This patch
prepares gdb's Ada tests to handle this situation by introducing a new
foreach_gnat_encoding.  A subsequent patch may change this to support
gnat-llvm; meanwhile this is a little cleaner anyway.
This commit is contained in:
Tom Tromey
2024-05-08 13:46:53 -06:00
parent f83ca9c7cc
commit a63b3b2f74
37 changed files with 93 additions and 97 deletions

View File

@@ -26,10 +26,8 @@ if {[is_aarch64_target]} {
}
}
foreach_with_prefix scenario {all minimal} {
set flags [list debug \
optimize=-O2 \
additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug optimize=-O2
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -19,8 +19,8 @@ require allow_ada_tests
standard_ada_testfile foo
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -19,8 +19,8 @@ require allow_ada_tests
standard_ada_testfile enum_with_gap_main
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" \
executable $flags] != ""} {

View File

@@ -19,8 +19,8 @@ require allow_ada_tests
standard_ada_testfile foo_q418_043
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -19,8 +19,8 @@ require allow_ada_tests
standard_ada_testfile foo
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -19,8 +19,8 @@ require allow_ada_tests
standard_ada_testfile foo
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -40,8 +40,8 @@ proc gdb_test_with_xfail { cmd re re_xfail msg } {
}
}
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -19,8 +19,8 @@ require allow_ada_tests
standard_ada_testfile foo
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -22,8 +22,8 @@ standard_ada_testfile foo
# Note we don't test the "none" (no -fgnat-encodings option) scenario
# here, because "all" and "minimal" cover the cases, and this way we
# don't have to update the test when gnat changes its default.
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -19,8 +19,8 @@ require allow_ada_tests
standard_ada_testfile foo
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -21,8 +21,8 @@ standard_ada_testfile foo_ra24_010
set old_gcc [expr [test_compiler_info {gcc-[0-8]-*}]]
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -19,8 +19,8 @@ require allow_ada_tests
standard_ada_testfile foo
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -19,8 +19,8 @@ require allow_ada_tests
standard_ada_testfile fixed
foreach_with_prefix gnat_encodings {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$gnat_encodings]
foreach_gnat_encoding gnat_encodings flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${gnat_encodings}" executable $flags] != "" } {
return -1

View File

@@ -19,8 +19,8 @@ require allow_ada_tests
standard_ada_testfile fixed_points
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1
}

View File

@@ -27,11 +27,10 @@ gdb_compile "${csrcfile}" "${cobject}" object [list debug]
# Note we don't test the "none" (no -fgnat-encodings option) scenario
# here, because "all" and "minimal" cover the cases, and this way we
# don't have to update the test when gnat changes its default.
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-largs \
additional_flags=${cobject} \
additional_flags=-margs \
additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug additional_flags=-largs \
additional_flags=${cobject} \
additional_flags=-margs
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -22,8 +22,8 @@ standard_ada_testfile foo
# Note we don't test the "none" (no -fgnat-encodings option) scenario
# here, because "all" and "minimal" cover the cases, and this way we
# don't have to update the test when gnat changes its default.
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -22,8 +22,8 @@ standard_ada_testfile bar
load_lib mi-support.exp
set MIFLAGS "-i=mi"
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -22,11 +22,8 @@ standard_ada_testfile bar
load_lib mi-support.exp
set MIFLAGS "-i=mi"
foreach_with_prefix scenario {none all minimal} {
set flags {debug}
if {$scenario != "none"} {
lappend flags additional_flags=-fgnat-encodings=$scenario
}
foreach_gnat_encoding scenario flags {none all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != "" } {
return -1

View File

@@ -24,11 +24,8 @@ set MIFLAGS "-i=mi"
set float "\\-?((\[0-9\]+(\\.\[0-9\]+)?(e\[-+\]\[0-9\]+)?)|(nan\\($hex\\)))"
foreach_with_prefix scenario {none all minimal} {
set flags {debug}
if {$scenario != "none"} {
lappend flags additional_flags=-fgnat-encodings=$scenario
}
foreach_gnat_encoding scenario flags {none all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != "" } {
return -1

View File

@@ -23,11 +23,8 @@ standard_ada_testfile pkg
load_lib mi-support.exp
set MIFLAGS "-i=mi"
foreach_with_prefix scenario {none all minimal} {
set flags {debug}
if {$scenario != "none"} {
lappend flags additional_flags=-fgnat-encodings=$scenario
}
foreach_gnat_encoding scenario flags {none all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -19,8 +19,8 @@ require allow_ada_tests
standard_ada_testfile foo
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -19,8 +19,8 @@ require allow_ada_tests
standard_ada_testfile p
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" \
executable $flags] != ""} {

View File

@@ -19,10 +19,8 @@ require allow_ada_tests
standard_ada_testfile foo_o224_021
foreach_with_prefix scenario {all minimal} {
set flags [list debug \
optimize=-O2 \
additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug optimize=-O2
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -19,8 +19,8 @@ require allow_ada_tests
standard_ada_testfile pa
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -19,8 +19,8 @@ require allow_ada_tests
standard_ada_testfile pr
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -22,11 +22,8 @@ standard_ada_testfile comp_bug
# Note we don't test the "none" (no -fgnat-encodings option) scenario
# here, because "all" and "minimal" cover the cases, and this way we
# don't have to update the test when gnat changes its default.
foreach_with_prefix scenario {all minimal} {
set flags {debug}
if {$scenario != "none"} {
lappend flags additional_flags=-fgnat-encodings=$scenario
}
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -19,8 +19,8 @@ require allow_ada_tests
standard_ada_testfile foo
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -21,8 +21,8 @@ require allow_ada_tests
standard_ada_testfile prog
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -22,8 +22,8 @@ standard_ada_testfile main
# Note we don't test the "none" (no -fgnat-encodings option) scenario
# here, because "all" and "minimal" cover the cases, and this way we
# don't have to update the test when gnat changes its default.
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -19,8 +19,8 @@ require allow_ada_tests
standard_ada_testfile foo
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != "" } {
return -1

View File

@@ -19,8 +19,8 @@ require allow_ada_tests
standard_ada_testfile foo
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -19,8 +19,8 @@ require allow_ada_tests
standard_ada_testfile foo
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -51,11 +51,8 @@ set pair_string { case ? is
}
set pair_full "type = record\n${inner_string}${pair_string}end record"
foreach_with_prefix scenario {none all minimal} {
set flags {debug}
if {$scenario != "none"} {
lappend flags additional_flags=-fgnat-encodings=$scenario
}
foreach_gnat_encoding scenario flags {none all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -22,8 +22,8 @@ standard_ada_testfile foo_na09_042
# Note we don't test the "none" (no -fgnat-encodings option) scenario
# here, because "all" and "minimal" cover the cases, and this way we
# don't have to update the test when gnat changes its default.
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -20,11 +20,8 @@ require allow_ada_tests
standard_ada_testfile pkg
foreach_with_prefix scenario {none all minimal} {
set flags {debug}
if {$scenario != "none"} {
lappend flags additional_flags=-fgnat-encodings=$scenario
}
foreach_gnat_encoding scenario flags {none all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -19,8 +19,8 @@ require allow_ada_tests
standard_ada_testfile foo
foreach_with_prefix scenario {all minimal} {
set flags [list debug additional_flags=-fgnat-encodings=$scenario]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
if {[gdb_compile_ada "${srcfile}" "${binfile}-${scenario}" executable $flags] != ""} {
return -1

View File

@@ -13,6 +13,25 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# A wrapper for foreach_with_prefix that applies suitable
# -fgnat-encodings arguments to a command line. SCENARIO_ARG is the
# name of a loop variable that will hold the scenario currently being
# evaluated. FLAGS_ARG will be set to the appropriate compiler flags
# (if any) for this scenario. LIST is the list of desired scenarios
# to run, and BODY is what actually does the work.
proc foreach_gnat_encoding {scenario_arg flags_arg list body} {
upvar 1 $scenario_arg scenario
upvar 1 $flags_arg flags
foreach_with_prefix scenario $list {
set flags {}
if {$scenario != "none"} {
lappend flags additional_flags=-fgnat-encodings=$scenario
}
uplevel 1 $body
}
}
# Call target_compile with SOURCE DEST TYPE and OPTIONS as argument,
# after having temporarily changed the current working directory to
# BUILDDIR.