Id : constant Entity_Id := Defining_Identifier (N);
Loc : constant Source_Ptr := Sloc (N);
Nam : constant Node_Id := Name (N);
- Is_Object_Ref : Boolean := False;
+ Is_Object_Ref : Boolean;
Dec : Node_Id;
T : Entity_Id;
T2 : Entity_Id;
if T = Any_Type or else Etype (Nam) = Any_Type then
return;
- -- Verify that the renamed entity is an object or function call.
+ -- Verify that the renamed entity is an object or function call
elsif Is_Object_Ref then
if Comes_From_Source (N) then
-- Note that predefined operators are functions as well, and so
-- are attributes that are (can be renamed as) functions.
- when N_Binary_Op
- | N_Function_Call
- | N_Unary_Op
+ when N_Function_Call
+ | N_Op
=>
return Etype (N) /= Standard_Void_Type;
-- of aggregates in more contexts.
when N_Qualified_Expression =>
- if Ada_Version < Ada_2012 then
- return False;
- else
- return Is_Object_Reference (Expression (N))
- or else Nkind (Expression (N)) = N_Aggregate;
- end if;
+ return Ada_Version >= Ada_2012
+ and then Is_Object_Reference (Expression (N));
+
+ -- In Ada 95 an aggreate is an object reference
+
+ when N_Aggregate =>
+ return Ada_Version >= Ada_95;
+
+ -- A string literal is not an object reference, but it might come
+ -- from rewriting of an object reference, e.g. from folding of an
+ -- aggregate.
+
+ when N_String_Literal =>
+ return Is_Rewrite_Substitution (N)
+ and then Is_Object_Reference (Original_Node (N));
when others =>
return False;