diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2020-03-04 09:32:03 +0100 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-06-10 09:34:55 -0400 |
commit | 895cf059f064bb0c86c333f9bd05fc95fa9e8d56 (patch) | |
tree | 8493970418911bdfb0e2b4e1c2226c130f8d74b5 /gcc | |
parent | c392a001491bd8603556bd922d073a96b6df8724 (diff) | |
download | gcc-895cf059f064bb0c86c333f9bd05fc95fa9e8d56.zip gcc-895cf059f064bb0c86c333f9bd05fc95fa9e8d56.tar.gz gcc-895cf059f064bb0c86c333f9bd05fc95fa9e8d56.tar.bz2 |
[Ada] Fix incorrect insertion of post-call actions in if-expression
2020-06-10 Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* exp_ch6.adb (Insert_Post_Call_Actions): Deal with the context
of an if-expression and with a call written in prefixed notation.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/exp_ch6.adb | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 5a0cbf4..db96fb7 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -7810,12 +7810,15 @@ package body Exp_Ch6 is return; end if; - -- Cases where the call is not a member of a statement list. This - -- includes the case where the call is an actual in another function - -- call or indexing, i.e. an expression context as well. + -- Cases where the call is not a member of a statement list. This also + -- includes the cases where the call is an actual in another function + -- call, or is an index, or is an operand of an if-expression, i.e. is + -- in an expression context. if not Is_List_Member (N) - or else Nkind_In (Context, N_Function_Call, N_Indexed_Component) + or else Nkind_In (Context, N_Function_Call, + N_If_Expression, + N_Indexed_Component) then -- In Ada 2012 the call may be a function call in an expression -- (since OUT and IN OUT parameters are now allowed for such calls). @@ -7823,7 +7826,9 @@ package body Exp_Ch6 is -- but the constraint checks generated when subtypes of formal and -- actual don't match must be inserted in the form of assignments. - if Nkind (Original_Node (N)) = N_Function_Call then + if Nkind (N) = N_Function_Call + or else Nkind (Original_Node (N)) = N_Function_Call + then pragma Assert (Ada_Version >= Ada_2012); -- Functions with '[in] out' parameters are only allowed in Ada -- 2012. |