[Ada] AI12-0132 Freezing of renames_as_body
authorArnaud Charlet <charlet@adacore.com>
Thu, 11 Jun 2020 18:31:54 +0000 (14:31 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 16 Jul 2020 09:18:19 +0000 (05:18 -0400)
gcc/ada/

* sem_ch8.adb (Analyze_Subprogram_Renaming): A renames-as-body
freezes the expression of any expression function that it
renames.

gcc/ada/sem_ch8.adb

index 695ff739b4d2ac47407fec547e027a4251b10fef..8411f5b5805f6c944bcfb6888d66ecc6f17551eb 100644 (file)
@@ -3160,6 +3160,22 @@ package body Sem_Ch8 is
             Error_Msg_NE ("subprogram& is not overriding", N, Rename_Spec);
          end if;
 
+         --  AI12-0132: a renames-as-body freezes the expression of any
+         --  expression function that it renames.
+
+         if Is_Entity_Name (Nam)
+           and then Is_Expression_Function (Entity (Nam))
+           and then not Inside_A_Generic
+         then
+            Freeze_Expr_Types
+              (Def_Id => Entity (Nam),
+               Typ    => Etype (Entity (Nam)),
+               Expr   =>
+                 Expression
+                   (Original_Node (Unit_Declaration_Node (Entity (Nam)))),
+               N      => N);
+         end if;
+
       --  Normal subprogram renaming (not renaming as body)
 
       else