https://gcc.gnu.org/g:3b0aebd70df2818e8fef81c45cdad96819534b73

commit r16-3683-g3b0aebd70df2818e8fef81c45cdad96819534b73
Author: Ghjuvan Lacambre <[email protected]>
Date:   Fri Jul 25 19:56:11 2025 +0200

    ada: exp_ch6.adb: perform less checks in CodePeer_Mode
    
    As explained in the comments, the CodePeer_Mode AST isn't well-formed
    for a GCC back-end, but is fine for a CodePeer one. The checks ensuring
    that the AST is well-formed thus need to be disabled.
    
    gcc/ada/ChangeLog:
    
            * exp_ch6.adb (Check_BIP_Actuals, Process_Node): Disable checks.

Diff:
---
 gcc/ada/exp_ch6.adb | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
index a58fb667c8e8..19812ad7cc16 100644
--- a/gcc/ada/exp_ch6.adb
+++ b/gcc/ada/exp_ch6.adb
@@ -1423,13 +1423,6 @@ package body Exp_Ch6 is
       Formal : Entity_Id;
 
    begin
-      pragma Assert (Nkind (Subp_Call) in N_Entry_Call_Statement
-                                        | N_Function_Call
-                                        | N_Procedure_Call_Statement);
-      pragma Assert (Extra_Formals_Known (Subp_Id)
-        or else not Expander_Active
-        or else Is_Unsupported_Extra_Actuals_Call (Subp_Call, Subp_Id));
-
       --  In CodePeer_Mode, the tree for `'Elab_Spec` procedures will be
       --  malformed because GNAT does not perform the usual expansion that
       --  results in the importation of external elaboration procedure symbols.
@@ -1447,6 +1440,13 @@ package body Exp_Ch6 is
          return True;
       end if;
 
+      pragma Assert (Nkind (Subp_Call) in N_Entry_Call_Statement
+                                        | N_Function_Call
+                                        | N_Procedure_Call_Statement);
+      pragma Assert (Extra_Formals_Known (Subp_Id)
+        or else not Expander_Active
+        or else Is_Unsupported_Extra_Actuals_Call (Subp_Call, Subp_Id));
+
       Formal := First_Formal_With_Extras (Subp_Id);
       Actual := First_Actual (Subp_Call);
 
@@ -10274,11 +10274,18 @@ package body Exp_Ch6 is
                begin
                   pragma Assert (Check_BIP_Actuals (Call_Node, Subp));
 
-                  --  Build-in-place function calls return their result by
-                  --  reference.
+                  --  Do not attempt to verify the return type in CodePeer_Mode
+                  --  as CodePeer_Mode is missing some expansion code that
+                  --  results in trees that would be considered malformed for
+                  --  GCC but aren't for GNAT2SCIL.
 
-                  pragma Assert (not Is_Build_In_Place_Function (Subp)
-                    or else Returns_By_Ref (Subp));
+                  if not CodePeer_Mode then
+                    --  Build-in-place function calls return their result by
+                    --  reference.
+
+                     pragma Assert (not Is_Build_In_Place_Function (Subp)
+                       or else Returns_By_Ref (Subp));
+                  end if;
                end;
 
             --  Skip generic bodies

Reply via email to