aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2020-03-10 09:09:25 +0100
committerPierre-Marie de Rodat <derodat@adacore.com>2020-06-10 09:35:01 -0400
commit67a44a4c109e6b2e684e96c346ec0f0fc1f56591 (patch)
treecfa61f97e3a0d27256514dcc03fa965dcf299b47
parente156631a27d599f118ef2d384c6974172cd0c74d (diff)
downloadgcc-67a44a4c109e6b2e684e96c346ec0f0fc1f56591.zip
gcc-67a44a4c109e6b2e684e96c346ec0f0fc1f56591.tar.gz
gcc-67a44a4c109e6b2e684e96c346ec0f0fc1f56591.tar.bz2
[Ada] Implement AI12-0162 Memberships and Unchecked_Unions
2020-06-10 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * exp_ch4.adb (Expand_N_In): Use an expression with actions to insert the PE raise statement for the Unchecked_Union case.
-rw-r--r--gcc/ada/exp_ch4.adb23
1 files changed, 12 insertions, 11 deletions
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index cd10935..d416c06 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -6527,23 +6527,24 @@ package body Exp_Ch4 is
goto Leave;
- -- Ada 2005 (AI-216): Program_Error is raised when evaluating
- -- a membership test if the subtype mark denotes a constrained
- -- Unchecked_Union subtype and the expression lacks inferable
- -- discriminants.
+ -- Ada 2005 (AI95-0216 amended by AI12-0162): Program_Error is
+ -- raised when evaluating an individual membership test if the
+ -- subtype mark denotes a constrained Unchecked_Union subtype
+ -- and the expression lacks inferable discriminants.
elsif Is_Unchecked_Union (Base_Type (Typ))
and then Is_Constrained (Typ)
and then not Has_Inferable_Discriminants (Lop)
then
- Insert_Action (N,
- Make_Raise_Program_Error (Loc,
- Reason => PE_Unchecked_Union_Restriction));
-
- -- Prevent Gigi from generating incorrect code by rewriting the
- -- test as False. What is this undocumented thing about ???
+ Rewrite (N,
+ Make_Expression_With_Actions (Loc,
+ Actions =>
+ New_List (Make_Raise_Program_Error (Loc,
+ Reason => PE_Unchecked_Union_Restriction)),
+ Expression =>
+ New_Occurrence_Of (Standard_False, Loc)));
+ Analyze_And_Resolve (N, Restyp);
- Rewrite (N, New_Occurrence_Of (Standard_False, Loc));
goto Leave;
end if;