-- Also, if the expression is of an access type whose designated type is
-- incomplete, then the access value must be null and we suppress the
- -- check.
+ -- check. We also need to suppress it for a class-wide type whose root
+ -- type has no discriminants.
if Known_Null (N) then
return;
elsif Is_Access_Type (S_Typ) then
S_Typ := Designated_Type (S_Typ);
- if Ekind (S_Typ) = E_Incomplete_Type then
+ if Ekind (S_Typ) = E_Incomplete_Type
+ or else (Is_Class_Wide_Type (S_Typ)
+ and then not Has_Discriminants (Root_Type (S_Typ)))
+ then
return;
end if;
end if;
-- Case of converting to an access type
if Is_Access_Type (Target_Type) then
+ -- Generate a null access check first for the sake of ACATS c3a0025
+
+ Apply_Constraint_Check (Operand, Target_Type);
+
-- In terms of accessibility rules, an anonymous access discriminant
-- is not considered separate from its parent object.
-- Case of conversions of tagged types and access to tagged types
- -- When needed, that is to say when the expression is class-wide, Add
+ -- When needed, that is to say when the expression is class-wide, add
-- runtime a tag check for (strict) downward conversion by using the
-- membership test, generating:
end if;
end Tagged_Conversion;
- -- Case of other access type conversions
-
- elsif Is_Access_Type (Target_Type) then
- Apply_Constraint_Check (Operand, Target_Type);
-
-- Case of conversions from a fixed-point type
-- These conversions require special expansion and processing, found in
return Is_Return_Object (Defining_Identifier (P))
and then Exp_Defines_Or_Is_Tied_To_Return_Value;
+ -- Something assigned to a return object is a return value
+
+ when N_Assignment_Statement =>
+ return Is_Entity_Name (Name (P))
+ and then Is_Return_Object (Entity (Name (P)))
+ and then Exp_Defines_Or_Is_Tied_To_Return_Value;
+
-- An allocator is not a return value unless specially built
when N_Allocator =>