diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2020-03-30 12:38:01 +0200 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-06-15 04:04:19 -0400 |
commit | 36cf595c0b8919dc261771fc5bea0c8b5614ab60 (patch) | |
tree | 05b0377f8b8f186fa478b422cc34fd85a14b95e9 /gcc | |
parent | 1fab710d0694d487fbd4943cdec240f2dcfda496 (diff) | |
download | gcc-36cf595c0b8919dc261771fc5bea0c8b5614ab60.zip gcc-36cf595c0b8919dc261771fc5bea0c8b5614ab60.tar.gz gcc-36cf595c0b8919dc261771fc5bea0c8b5614ab60.tar.bz2 |
[Ada] Implement AI12-0077 Has_Same_Storage on objects of size zero
2020-06-15 Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* exp_attr.adb (Expand_N_Attribute_Reference) <Has_Same_Storage>:
Do not do superfluous work. Add the condition (X'Size /= 0) on
both paths and turn binary AND into short-circuit AND THEN.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/exp_attr.adb | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index 5faa1ce..a7b9007 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -3603,6 +3603,7 @@ package body Exp_Attr is -- (X'address = Y'address) -- and then (X'Size = Y'Size) + -- and then (X'Size /= 0) (AI12-0077) -- If both arguments have the same Etype the second conjunct can be -- omitted. @@ -3622,27 +3623,39 @@ package body Exp_Attr is Attribute_Name => Name_Size, Prefix => New_Copy_Tree (X)); - Y_Size := - Make_Attribute_Reference (Loc, - Attribute_Name => Name_Size, - Prefix => New_Copy_Tree (Y)); - if Etype (X) = Etype (Y) then Rewrite (N, - Make_Op_Eq (Loc, - Left_Opnd => X_Addr, - Right_Opnd => Y_Addr)); + Make_And_Then (Loc, + Left_Opnd => + Make_Op_Eq (Loc, + Left_Opnd => X_Addr, + Right_Opnd => Y_Addr), + Right_Opnd => + Make_Op_Ne (Loc, + Left_Opnd => X_Size, + Right_Opnd => Make_Integer_Literal (Loc, 0)))); else + Y_Size := + Make_Attribute_Reference (Loc, + Attribute_Name => Name_Size, + Prefix => New_Copy_Tree (Y)); + Rewrite (N, - Make_Op_And (Loc, + Make_And_Then (Loc, Left_Opnd => Make_Op_Eq (Loc, Left_Opnd => X_Addr, Right_Opnd => Y_Addr), Right_Opnd => - Make_Op_Eq (Loc, - Left_Opnd => X_Size, - Right_Opnd => Y_Size))); + Make_And_Then (Loc, + Left_Opnd => + Make_Op_Eq (Loc, + Left_Opnd => X_Size, + Right_Opnd => Y_Size), + Right_Opnd => + Make_Op_Ne (Loc, + Left_Opnd => New_Copy_Tree (X_Size), + Right_Opnd => Make_Integer_Literal (Loc, 0))))); end if; Analyze_And_Resolve (N, Standard_Boolean); |