The body that is a rewriting of an expression function does not freeze previous entities.
The following must compile quietly in Ada2012 mode: --- package Ada12 is type T is tagged null record; function Template (Self : T) return String is ("foo.thtml"); type T2 is new T with null record; overriding function Template (Self : T2) return String is ("bar.thtml"); end Ada12; Tested on x86_64-pc-linux-gnu, committed on trunk 2011-09-06 Ed Schonberg <schonb...@adacore.com> * sem_ch6.adb (Analyze_Subprogram_Body_Helper): The body that is a rewriting of an expression function does not freeze previous entities.
Index: sem_ch6.adb =================================================================== --- sem_ch6.adb (revision 178567) +++ sem_ch6.adb (working copy) @@ -2346,7 +2346,12 @@ -- expansion has generated an equivalent type that is used when -- elaborating the body. - if No (Spec_Id) then + -- An exception in the case of Ada2012, AI05-177: The bodies + -- created for expression functions do not freeze. + + if No (Spec_Id) + and then Nkind (Original_Node (N)) /= N_Expression_Function + then Freeze_Before (N, Body_Id); elsif Nkind (Parent (N)) = N_Compilation_Unit then