aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarc Poulhiès <poulhies@adacore.com>2024-05-23 11:57:54 +0200
committerMarc Poulhiès <poulhies@adacore.com>2024-05-31 11:58:50 +0200
commite0ab5ee9bed5cbad9ae344a23ff0d302b8279d32 (patch)
treea36b7b3db85d77191970819478b830cd3fe6c4c4 /gcc
parent37fafc63e732c51900d2d998b6df6433d9ca6e2f (diff)
downloadgcc-e0ab5ee9bed5cbad9ae344a23ff0d302b8279d32.zip
gcc-e0ab5ee9bed5cbad9ae344a23ff0d302b8279d32.tar.gz
gcc-e0ab5ee9bed5cbad9ae344a23ff0d302b8279d32.tar.bz2
fix: valid compiler optimization may fail the test
cxa4001 may fail with "Exception not raised" when the compiler omits the calls to To_Mapping, in accordance with 10.2.1(18/3): "If a library unit is declared pure, then the implementation is permitted to omit a call on a library-level subprogram of the library unit if the results are not needed after the call" Using the result of both To_Mapping calls prevents the compiler from omitting them. "The corrected test will be available on the ACAA web site (http://www.ada-auth.org/), and will be issued with the Modified Tests List version 2.6K, 3.1DD, and 4.1GG." gcc/testsuite/ChangeLog: * ada/acats/tests/cxa/cxa4001.a: Use function result.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ada/acats/tests/cxa/cxa4001.a12
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/testsuite/ada/acats/tests/cxa/cxa4001.a b/gcc/testsuite/ada/acats/tests/cxa/cxa4001.a
index d850acd..52fabc3 100644
--- a/gcc/testsuite/ada/acats/tests/cxa/cxa4001.a
+++ b/gcc/testsuite/ada/acats/tests/cxa/cxa4001.a
@@ -185,6 +185,12 @@ begin
begin
Bad_Map := Maps.To_Mapping(From => "aa", To => "yz");
Report.Failed("Exception not raised with repeated character");
+
+ if Report.Equal (Character'Pos('y'),
+ Character'Pos(Maps.Value(Bad_Map, 'a'))) then
+ -- Use the map to avoid optimization.
+ Report.Comment ("Shouldn't get here.");
+ end if;
exception
when Translation_Error => null; -- OK
when others =>
@@ -200,6 +206,12 @@ begin
begin
Bad_Map := Maps.To_Mapping("abc", "yz");
Report.Failed("Exception not raised with unequal parameter lengths");
+
+ if Report.Equal (Character'Pos('y'),
+ Character'Pos(Maps.Value(Bad_Map, 'a'))) then
+ -- Use the map to avoid optimization.
+ Report.Comment ("Shouldn't get here.");
+ end if;
exception
when Translation_Error => null; -- OK
when others =>