diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2013-01-18 12:34:11 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2013-01-18 12:34:11 -0800 |
commit | 43269d882367dc4f0e4c2651d6625e1b7de78764 (patch) | |
tree | 6aaf525a6fb8a4fb63a71c9ca56be58bc1d6655b /gcc/ada/exp_attr.adb | |
parent | ce97ec0e268b7b50b9f801dd12ffc67042c47193 (diff) | |
parent | 48dc1117de124a2265129a36bfbbc211522c2c02 (diff) | |
download | gcc-43269d882367dc4f0e4c2651d6625e1b7de78764.tar.gz |
Merge remote-tracking branch 'origin/gcc-4_7-branch' into hjl/tsx/gcc-4_7-branchhjl/tsx/gcc-4_7-branch
Conflicts:
gcc/config/i386/driver-i386.c
gcc/config/i386/i386.c
gcc/config/i386/sync.md
Diffstat (limited to 'gcc/ada/exp_attr.adb')
-rw-r--r-- | gcc/ada/exp_attr.adb | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index 4e0c60cdb57..b2f53ec6bd0 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -2996,9 +2996,26 @@ package body Exp_Attr is -- Max_Size_In_Storage_Elements -- ---------------------------------- - when Attribute_Max_Size_In_Storage_Elements => + when Attribute_Max_Size_In_Storage_Elements => declare + Typ : constant Entity_Id := Etype (N); + Attr : Node_Id; + + Conversion_Added : Boolean := False; + -- A flag which tracks whether the original attribute has been + -- wrapped inside a type conversion. + + begin Apply_Universal_Integer_Attribute_Checks (N); + -- The universal integer check may sometimes add a type conversion, + -- retrieve the original attribute reference from the expression. + + Attr := N; + if Nkind (Attr) = N_Type_Conversion then + Attr := Expression (Attr); + Conversion_Added := True; + end if; + -- Heap-allocated controlled objects contain two extra pointers which -- are not part of the actual type. Transform the attribute reference -- into a runtime expression to add the size of the hidden header. @@ -3007,20 +3024,20 @@ package body Exp_Attr is -- two pointers are already present in the type. if VM_Target = No_VM - and then Nkind (N) = N_Attribute_Reference + and then Nkind (Attr) = N_Attribute_Reference and then Needs_Finalization (Ptyp) - and then not Header_Size_Added (N) + and then not Header_Size_Added (Attr) then - Set_Header_Size_Added (N); + Set_Header_Size_Added (Attr); -- Generate: -- P'Max_Size_In_Storage_Elements + -- Universal_Integer -- (Header_Size_With_Padding (Ptyp'Alignment)) - Rewrite (N, + Rewrite (Attr, Make_Op_Add (Loc, - Left_Opnd => Relocate_Node (N), + Left_Opnd => Relocate_Node (Attr), Right_Opnd => Convert_To (Universal_Integer, Make_Function_Call (Loc, @@ -3034,9 +3051,19 @@ package body Exp_Attr is New_Reference_To (Ptyp, Loc), Attribute_Name => Name_Alignment)))))); - Analyze (N); + -- Add a conversion to the target type + + if not Conversion_Added then + Rewrite (Attr, + Make_Type_Conversion (Loc, + Subtype_Mark => New_Reference_To (Typ, Loc), + Expression => Relocate_Node (Attr))); + end if; + + Analyze (Attr); return; end if; + end; -------------------- -- Mechanism_Code -- |