The compiler now uses Replace instead of Rewrite, when the semantic analyzer discovers that what looked like a selected component was in factt a function call. This avoids a special case in ASIS for handling an undecorated original node. This is an internal change only with no functional effect (basically it is a cleanup in the interface between the front end and ASIS).
The following test, compiled with -gnatdt 1. procedure Ololo is 2. type Rec is record 3. C : Integer; 4. end record; 5. Rec_0 : Rec := (C => 0); 6. function Fun return Rec is 7. begin 8. return Rec_0; 9. end Fun; 10. I : Integer; 11. begin 12. I := Ololo.Fun.C; 13. end Ololo; generates output which does NOT contain any instance of the string: Rewritten: original node = N_Expanded_Name Previously there was one occurrence Tested on x86_64-pc-linux-gnu, committed on trunk 2014-01-27 Robert Dewar <de...@adacore.com> * sem_ch8.adb (Find_Selected_Component): Use Replace instead of Rewrite.
Index: sem_ch8.adb =================================================================== --- sem_ch8.adb (revision 207120) +++ sem_ch8.adb (working copy) @@ -6296,9 +6296,10 @@ -- If no interpretation as an expanded name is possible, it -- must be a selected component of a record returned by a -- function call. Reformat prefix as a function call, the rest - -- is done by type resolution. If the prefix is procedure or - -- entry, as is P.X; this is an error. + -- is done by type resolution. + -- Error if the prefix is procedure or entry, as is P.X + if Ekind (P_Name) /= E_Function and then (not Is_Overloaded (P) @@ -6309,7 +6310,6 @@ -- chain, the candidate package may be anywhere on it. if Present (Homonym (Current_Entity (P_Name))) then - P_Name := Current_Entity (P_Name); while Present (P_Name) loop @@ -6327,6 +6327,7 @@ Set_Entity (Prefix (N), P_Name); Find_Expanded_Name (N); return; + else P_Name := Entity (Prefix (N)); end if; @@ -6338,11 +6339,27 @@ Set_Entity (N, Any_Id); Set_Etype (N, Any_Type); + -- Here we have a function call, so do the reformatting + else Nam := New_Copy (P); Save_Interps (P, Nam); - Rewrite (P, + + -- We use Replace here because this is one of those cases + -- where the parser has missclassified the node, and we + -- fix things up and then do the semantic analysis on the + -- fixed up node. Normally we do this using one of the + -- Sinfo.CN routines, but this is too tricky for that. + + -- Note that using Rewrite would be wrong, because we + -- would have a tree where the original node is unanalyzed, + -- and this violates the required interface for ASIS. + + Replace (P, Make_Function_Call (Sloc (P), Name => Nam)); + + -- Now analyze the reformatted node + Analyze_Call (P); Analyze_Selected_Component (N); end if;