This expands on the reason for properly guarding the transformation.
gcc/ada/
* exp_ch6.adb (Expand_Ctrl_Function_Call): Rework last comment.
Set_Analyzed (N);
- -- Apply the transformation, unless it was already applied manually
+ -- Apply the transformation unless it was already applied earlier. This
+ -- may happen because Remove_Side_Effects can be called during semantic
+ -- analysis, for example from Build_Actual_Subtype_Of_Component. It is
+ -- crucial to avoid creating a reference of reference here, because it
+ -- would not be subsequently recognized by the Is_Finalizable_Transient
+ -- and Requires_Cleanup_Actions predicates.
if Nkind (Par) /= N_Reference then
Remove_Side_Effects (N);