aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Squirek <squirek@adacore.com>2020-07-22 08:13:24 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-10-20 03:21:45 -0400
commitabc694ce7c956a38d2e8057496e25766cf0e216a (patch)
tree7133f661c9d842edd06f770f0f291f22d798b42a
parentc01c11cc9cbb2d2a78f03c7c90d98149fd650a95 (diff)
downloadgcc-abc694ce7c956a38d2e8057496e25766cf0e216a.zip
gcc-abc694ce7c956a38d2e8057496e25766cf0e216a.tar.gz
gcc-abc694ce7c956a38d2e8057496e25766cf0e216a.tar.bz2
[Ada] Crash on cond expression as actual for anonymous access formal
gcc/ada/ * exp_ch6.adb (Expand_Branch): Properly anticipate expansion of conditional expressions producing object declarations in addition to assignment statements, and rename formal.
-rw-r--r--gcc/ada/exp_ch6.adb27
1 files changed, 16 insertions, 11 deletions
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
index dd555a2..9b7efc2 100644
--- a/gcc/ada/exp_ch6.adb
+++ b/gcc/ada/exp_ch6.adb
@@ -3961,42 +3961,47 @@ package body Exp_Ch6 is
procedure Insert_Level_Assign (Branch : Node_Id) is
- procedure Expand_Branch (Assn : Node_Id);
+ procedure Expand_Branch (Res_Assn : Node_Id);
-- Perform expansion or iterate further within
- -- nested conditionals.
+ -- nested conditionals given the object
+ -- declaration or assignment to result object
+ -- created during expansion which represents
+ -- a branch of the conditional expression.
-------------------
-- Expand_Branch --
-------------------
- procedure Expand_Branch (Assn : Node_Id) is
+ procedure Expand_Branch (Res_Assn : Node_Id) is
begin
- pragma Assert (Nkind (Assn) =
- N_Assignment_Statement);
+ pragma Assert (Nkind (Res_Assn) in
+ N_Assignment_Statement |
+ N_Object_Declaration);
-- There are more nested conditional
-- expressions so we must go deeper.
- if Nkind (Expression (Assn)) =
+ if Nkind (Expression (Res_Assn)) =
N_Expression_With_Actions
and then
Nkind
- (Original_Node (Expression (Assn))) in
- N_Case_Expression | N_If_Expression
+ (Original_Node (Expression (Res_Assn)))
+ in N_Case_Expression | N_If_Expression
then
- Insert_Level_Assign (Expression (Assn));
+ Insert_Level_Assign
+ (Expression (Res_Assn));
-- Add the level assignment
else
- Insert_Before_And_Analyze (Assn,
+ Insert_Before_And_Analyze (Res_Assn,
Make_Assignment_Statement (Loc,
Name =>
New_Occurrence_Of
(Lvl, Loc),
Expression =>
Dynamic_Accessibility_Level
- (Expression (Assn))));
+ (Expression (Res_Assn))));
end if;
end Expand_Branch;