-- Special casing for identifiers and other entity names and operators
- if Nkind (New_N) in N_Character_Literal
- | N_Expanded_Name
- | N_Identifier
- | N_Operator_Symbol
- | N_Op
+ if Nkind (N) in N_Character_Literal
+ | N_Expanded_Name
+ | N_Identifier
+ | N_Operator_Symbol
+ | N_Op
then
if not Instantiating then
then
Set_Entity (New_N, Assoc);
+ -- Cope with the rewriting into expanded name that may have
+ -- occurred in between, e.g. in Check_Generic_Child_Unit for
+ -- generic renaming declarations.
+
+ elsif Nkind (Assoc) = N_Expanded_Name then
+ Rewrite (N, New_Copy_Tree (Assoc));
+ Set_Associated_Node (N, Assoc);
+ return Copy_Generic_Node (N, Parent_Id, Instantiating);
+
-- The name in the call may be a selected component if the
-- call has not been analyzed yet, as may be the case for
-- pre/post conditions in a generic unit.
Set_Entity (New_N, Entity (Name (Assoc)));
elsif Nkind (Assoc) in N_Entity
- and then (Expander_Active or
- (GNATprove_Mode
- and then not In_Spec_Expression
- and then not Inside_A_Generic))
+ and then (Expander_Active
+ or else (GNATprove_Mode
+ and then not In_Spec_Expression
+ and then not Inside_A_Generic))
then
-- Inlining case: we are copying a tree that contains
-- global entities, which are preserved in the copy to be