]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Introduce and use foreach_gnat_encoding
authorTom Tromey <tromey@adacore.com>
Wed, 8 May 2024 19:46:53 +0000 (13:46 -0600)
committerTom Tromey <tromey@adacore.com>
Fri, 6 Sep 2024 16:22:13 +0000 (10:22 -0600)
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.

37 files changed:
gdb/testsuite/gdb.ada/O2_float_param.exp
gdb/testsuite/gdb.ada/access_to_unbounded_array.exp
gdb/testsuite/gdb.ada/arr_acc_idx_w_gap.exp
gdb/testsuite/gdb.ada/arr_enum_idx_w_gap.exp
gdb/testsuite/gdb.ada/array_of_symbolic_length.exp
gdb/testsuite/gdb.ada/array_of_variable_length.exp
gdb/testsuite/gdb.ada/array_of_variant.exp
gdb/testsuite/gdb.ada/array_ptr_renaming.exp
gdb/testsuite/gdb.ada/arrayparam.exp
gdb/testsuite/gdb.ada/arrayptr.exp
gdb/testsuite/gdb.ada/big_packed_array.exp
gdb/testsuite/gdb.ada/enum_idx_packed.exp
gdb/testsuite/gdb.ada/fixed_cmp.exp
gdb/testsuite/gdb.ada/fixed_points.exp
gdb/testsuite/gdb.ada/frame_arg_lang.exp
gdb/testsuite/gdb.ada/funcall_ref.exp
gdb/testsuite/gdb.ada/mi_string_access.exp
gdb/testsuite/gdb.ada/mi_var_array.exp
gdb/testsuite/gdb.ada/mi_var_union.exp
gdb/testsuite/gdb.ada/mi_variant.exp
gdb/testsuite/gdb.ada/mod_from_name.exp
gdb/testsuite/gdb.ada/multiarray.exp
gdb/testsuite/gdb.ada/out_of_line_in_inlined.exp
gdb/testsuite/gdb.ada/packed_array.exp
gdb/testsuite/gdb.ada/packed_record.exp
gdb/testsuite/gdb.ada/packed_tagged.exp
gdb/testsuite/gdb.ada/pckd_arr_ren.exp
gdb/testsuite/gdb.ada/ptype-o.exp
gdb/testsuite/gdb.ada/rec_ptype.exp
gdb/testsuite/gdb.ada/same_component_name.exp
gdb/testsuite/gdb.ada/set_pckd_arr_elt.exp
gdb/testsuite/gdb.ada/unc_arr_ptr_in_var_rec.exp
gdb/testsuite/gdb.ada/unchecked_union.exp
gdb/testsuite/gdb.ada/var_rec_arr.exp
gdb/testsuite/gdb.ada/variant.exp
gdb/testsuite/gdb.ada/variant_record_packed_array.exp
gdb/testsuite/lib/ada.exp

index d44f2e57217f284ad35c5484a49aba4ae0badf0f..86b67ff4626fc1c92610bca2787d4aa4c0f54f69 100644 (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
index 7f7bfb3ba4c175c89aa4d301818181030dca6e38..eeaceb018ed880160066ab3422ff2765a719d40f 100644 (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
index 569bb2ec55658366450d35f33ce3380980987732..4ecb4f8cd78ecb4ec95b53378514431dff4b212c 100644 (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] != ""} {
index 5a88f5f3ca9b09e34ebabeeb3933172cd6796495..491402bd78ab9e8cb2ec431b6c9718d996274509 100644 (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
index bcf73690801094412a3e9e099ce5c2bb11ec40a5..134b448e64a9980b3328af4bef756c4df40ee3bc 100644 (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
index 3397760e16c8aaccf1a489618f0a6f276bdd6a64..3c68c805a122a1d0dd3695e7c8cb45ed009ef9f4 100644 (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
index 1a155d416db28bff4d98a6c3897c0ebb76eb6e0a..f93260af940f34afb88af60ca2aea2b475a118b8 100644 (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
index b013fc7e3b60a2d1ab046489c1796597e1ba5a32..eadfcb64891c8ce1db9cc96e83ad54b59528ff6a 100644 (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
index 2921d64bef1522a90dd7374300f3cb62dea45f33..ef00037be90a0e47ec9b2bb9adb282d5dbf56c54 100644 (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
index ca48993439b6a0e31a4ce59e8fea72f13dcbb76a..335573b31a7979fd71c0db69061e012f041d4d80 100644 (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
index 1ba2c4853c8779cdac07a64637ab3338aa8bd45f..0078c77de6af7e9a7eba485061bc6d737645a426 100644 (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
index 1976092c13b0bbaa37f8e409591af2e5ce8bea38..d56d73bf9bc339d3ee8caf9d223bb0880a9f88de 100644 (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
index de506fdfd991fc0b6297d34a698fdd5513796aeb..dcd474553028460188fadfbcbc1bce90b2a6f636 100644 (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
index 4665595f6f8eae46b9e1ee00b7e506091be383cc..ceed34acbc536f03533f2349999c9d3c53098cd7 100644 (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
     }
index 918a922ca2fa43a2b8e9dccbb7641e17497fc853..b629c429ac8909fef41ac856a9d3e3627f37624e 100644 (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
index 518ceb7118f2ccb615b395e3c47d8f3b8bbce622..1c2839230218946dee883d8f9274d25629cc5f40 100644 (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
index 15b8cf153f462da3e0016ae642b6190f698fc512..8fd116b545c00e00b069034f63a66e736ebbce09 100644 (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
index 2b50481509908211b1cb51c7b624de97476b7e64..dd770a1171824bc60aaa3e8cac8cbc3d9e396cf3 100644 (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
index eb23c0a4a6559c0324fc970624d2329b4d6e0871..64bfe3355e77a4b1ac2ddb0309d5bed657bd6690 100644 (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
index 7f10b3c511f98eaf8609bdd939f0cb3b9ecd0806..f4be5a0b110bd6753ff5b1eddf7520afa3f14f0a 100644 (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
index c6acc802bbf9a7ddd003a142ae425edcbbc0dea6..33bd854d3ba321ce8b3827032fc95a52f022601e 100644 (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
index 9be0aaabeee20a167c296e71b8031820f9d59347..91ba1ec003409d1c38fba5ad78b94462a2ed9455 100644 (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] != ""} {
index eaa88a30774ad96cb3a4c08caa8f31acde848051..2adef97e7633264613bd505ab7cf201dd1fd6329 100644 (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
index a3d7136c1639afec7185d2510ae61ed05714b28f..85bc59db882720f93ea848f84d4cdf37bfa3b804 100644 (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
index fa058f705248a313da36530275c79586d500f5f4..bbba9b25c54a8e0169641ecfa2af5b5df7e1f58b 100644 (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
index faccc1476d4c18e24ce3ba3da93aea763ac21153..1c9e5a07703bbef88721c3a7f20b7a41852ae64d 100644 (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
index 083ee13271403d3b8ea707012fa82face91030d3..18bb84f848a204ecaf75b96f040a69a6ab5222fd 100644 (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
index f7782199d5818ac47152117830c13ee84816d76a..5038ee171d2b126270181d37770a47d37319ba95 100644 (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
index f75d09b16ef0b1b5a88b563abb361b36335efbc1..fc7bb8b5fac5bb1000bad23afa1f420d7a604be3 100644 (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
index 7167a4124d1975a26205694122534ff2a2c167e7..84a48b4fd0ed722a22ad07677f5972806afd89af 100644 (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
index d77f8fe689691da96d0e344638cb93123281f401..2979cb99e833a75eebe0e76359ab8dc63b8033f9 100644 (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
index 6b2a6fdfa9ab176eca417d74e05d6e6bad959298..2bcc027cec4384e191e6e1a8b6a0e8383d54a570 100644 (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
index bff71bdaa2fb47a90778f51cf9f5b2ce26a1990e..5d3256bd52e22a2a98aeb622a7f9b90a7182d283 100644 (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
index a8591089ba89e408de3b1002997c0360546659b8..20598ea708c78c594a90d1b33af98e530b8da942 100644 (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
index 9fbc449758a38a092e71d24e5a5430c41dba768b..227331c3ac06f01d53223eec7945b5db2a64b247 100644 (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
index f6b4e4171a82fd357b5e97dbd535137beed55cfb..8f4192cfd4909263f49305b7a647e3f691aa9917 100644 (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
index 1bc0dc1d43820d7620905aad9473c985fa077580..0544544acbe54589c836ca0ce8ddc9025c2817ae 100644 (file)
 # 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.