mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-22 11:31:05 +08:00
[Ada] Spurious constraint error on conversion of access types
gcc/ada/ * checks.adb (Make_Discriminant_Constraint_Check): Add check for null when the type being converted is an access type.
This commit is contained in:
parent
5413faaec7
commit
55b93bbc21
@ -3658,6 +3658,20 @@ package body Checks is
|
||||
Cond := Build_Discriminant_Checks (Expr, Expr_Type);
|
||||
Set_Discriminant_Constraint (Expr_Type, Old_Constraints);
|
||||
|
||||
-- Conversion between access types requires that we check for null
|
||||
-- before checking discriminants.
|
||||
|
||||
if Is_Access_Type (Etype (Expr)) then
|
||||
Cond := Make_And_Then (Loc,
|
||||
Left_Opnd =>
|
||||
Make_Op_Ne (Loc,
|
||||
Left_Opnd =>
|
||||
Duplicate_Subexpr_No_Checks
|
||||
(Expr, Name_Req => True),
|
||||
Right_Opnd => Make_Null (Loc)),
|
||||
Right_Opnd => Cond);
|
||||
end if;
|
||||
|
||||
Insert_Action (N,
|
||||
Make_Raise_Constraint_Error (Loc,
|
||||
Condition => Cond,
|
||||
|
Loading…
x
Reference in New Issue
Block a user