diff options
author | Justin Squirek <squirek@adacore.com> | 2020-07-21 15:06:37 -0400 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-10-20 03:21:43 -0400 |
commit | 04b06947cbcfebaa1ba5beb3c9bf086af5beabab (patch) | |
tree | 13a51a85ee27dfba0ac311ae0087f4254fbbcfc2 | |
parent | 854f9a8167d49318a9b2318db64cf1b2c0297e29 (diff) | |
download | gcc-04b06947cbcfebaa1ba5beb3c9bf086af5beabab.zip gcc-04b06947cbcfebaa1ba5beb3c9bf086af5beabab.tar.gz gcc-04b06947cbcfebaa1ba5beb3c9bf086af5beabab.tar.bz2 |
[Ada] Hang on cond expression as actual for anonymous access formal
gcc/ada/
* exp_ch6.adb (Expand_Call_Helper): Properly handle the case
where the condition of a conditional expression has been
optimized out when calculating the value of an extra
accessibility parameter.
-rw-r--r-- | gcc/ada/exp_ch6.adb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 5d8e48b..dd555a2 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -4014,20 +4014,23 @@ package body Exp_Ch6 is -- Find the relevant statement in the actions Cond := First (Actions (Branch)); - loop + while Present (Cond) loop exit when Nkind (Cond) in N_Case_Statement | N_If_Statement; Next (Cond); - - if No (Cond) then - raise Program_Error; - end if; end loop; + -- The conditional expression may have been + -- optimized away, so examine the actions in + -- the branch. + + if No (Cond) then + Expand_Branch (Last (Actions (Branch))); + -- Iterate through if expression branches - if Nkind (Cond) = N_If_Statement then + elsif Nkind (Cond) = N_If_Statement then Expand_Branch (Last (Then_Statements (Cond))); Expand_Branch (Last (Else_Statements (Cond))); |