[gcc r11-1149] [Ada] Fix incorrect insertion of post-call actions in if-expression

Pierre-Marie de Rodat pmderodat@gcc.gnu.org
Wed Jun 10 13:35:43 GMT 2020


https://gcc.gnu.org/g:895cf059f064bb0c86c333f9bd05fc95fa9e8d56

commit r11-1149-g895cf059f064bb0c86c333f9bd05fc95fa9e8d56
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Wed Mar 4 09:32:03 2020 +0100

    [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.

Diff:
---
 gcc/ada/exp_ch6.adb | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
index 5a0cbf46c95..db96fb77922 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.


More information about the Gcc-cvs mailing list