]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Cleanup preanalysis of static expressions (part 3)
authorJavier Miranda <miranda@adacore.com>
Wed, 25 Dec 2024 06:42:10 +0000 (06:42 +0000)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 9 Jan 2025 08:22:45 +0000 (09:22 +0100)
Avoid reporting spurious errors.

gcc/ada/ChangeLog:

* freeze.adb (Freeze_Expr_Types): Reverse patch; that is, restore
calls to Preanalyze_Spec_Expression instead of Preanalyze_And_Resolve
for the sake of consistency with Analyze_Expression_Function. Patch
suggested by Eric Botcazou.
* exp_put_image.adb (Image_Should_Call_Put_Image): Ensure that
function Defining_Identifier is called with a proper node to
avoid internal assertion failure.

gcc/ada/exp_put_image.adb
gcc/ada/freeze.adb

index 38bde44ff5afd30fe885c35ed2041c53100f73cc..ae5fa40fa380fef34b7ce1c63be6f97146206b05 100644 (file)
@@ -1190,6 +1190,8 @@ package body Exp_Put_Image is
          --  aspects, not just for Put_Image?
 
          if Is_Itype (U_Type)
+           and then Nkind (Associated_Node_For_Itype (U_Type)) in
+                      N_Full_Type_Declaration | N_Subtype_Declaration
            and then Has_Aspect (Defining_Identifier
                                   (Associated_Node_For_Itype (U_Type)),
                                 Aspect_Put_Image)
index 10f0de78d9d7738478923e3fe9477d989554ef73..54b620214e80cfa5539317fbdbc618659f413b51 100644 (file)
@@ -9389,14 +9389,16 @@ package body Freeze is
       --  pre/postconditions during expansion of the subprogram body, the
       --  subprogram is already installed.
 
+      --  Call Preanalyze_Spec_Expression instead of Preanalyze_And_Resolve
+      --  for the sake of consistency with Analyze_Expression_Function.
+
       if Def_Id /= Current_Scope then
          Push_Scope (Def_Id);
          Install_Formals (Def_Id);
-
-         Preanalyze_And_Resolve (Dup_Expr, Typ);
+         Preanalyze_Spec_Expression (Dup_Expr, Typ);
          End_Scope;
       else
-         Preanalyze_And_Resolve (Dup_Expr, Typ);
+         Preanalyze_Spec_Expression (Dup_Expr, Typ);
       end if;
 
       --  Restore certain attributes of Def_Id since the preanalysis may