From dc9111cfce884749f12b88d43abb717e6d9d5f27 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Mon, 26 Oct 2015 10:47:56 +0000 Subject: [PATCH] freeze.adb (Check_Component_Storage_Order): Skip a record component if it has Complex_Representation. 2015-10-26 Eric Botcazou * freeze.adb (Check_Component_Storage_Order): Skip a record component if it has Complex_Representation. (Freeze_Record_Type): If the type has Complex_Representation, skip the regular treatment of Scalar_Storage_Order attribute and instead issue a warning if it is present. From-SVN: r229325 --- gcc/ada/ChangeLog | 8 ++++ gcc/ada/freeze.adb | 108 ++++++++++++++++++++++++++------------------- 2 files changed, 71 insertions(+), 45 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 232b1fc0b1b..5dff6de4fca 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,11 @@ +2015-10-26 Eric Botcazou + + * freeze.adb (Check_Component_Storage_Order): Skip a record + component if it has Complex_Representation. + (Freeze_Record_Type): If the type has Complex_Representation, skip the + regular treatment of Scalar_Storage_Order attribute and instead issue + a warning if it is present. + 2015-10-26 Bob Duff * sem_ch13.adb (Check_Iterator_Functions): For a Default_Iterator diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 081d7513c53..f67bc362265 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -1197,9 +1197,14 @@ package body Freeze is Attribute_Scalar_Storage_Order); Comp_ADC_Present := Present (Comp_ADC); - -- Case of record or array component: check storage order compatibility + -- Case of record or array component: check storage order compatibility. + -- But, if the record has Complex_Representation, then it is treated as + -- a scalar in the back end so the storage order is irrelevant. - if Is_Record_Type (Comp_Type) or else Is_Array_Type (Comp_Type) then + if (Is_Record_Type (Comp_Type) + and then not Has_Complex_Representation (Comp_Type)) + or else Is_Array_Type (Comp_Type) + then Comp_SSO_Differs := Reverse_Storage_Order (Encl_Type) /= @@ -3940,61 +3945,74 @@ package body Freeze is Next_Entity (Comp); end loop; - -- Deal with default setting of reverse storage order + SSO_ADC := + Get_Attribute_Definition_Clause + (Rec, Attribute_Scalar_Storage_Order); - Set_SSO_From_Default (Rec); + -- If the record type has Complex_Representation, then it is treated + -- as a scalar in the back end so the storage order is irrelevant. - -- Check consistent attribute setting on component types + if Has_Complex_Representation (Rec) then + if Present (SSO_ADC) then + Error_Msg_N + ("??storage order has no effect with Complex_Representation", + SSO_ADC); + end if; - SSO_ADC := Get_Attribute_Definition_Clause - (Rec, Attribute_Scalar_Storage_Order); + else + -- Deal with default setting of reverse storage order - declare - Comp_ADC_Present : Boolean; - begin - Comp := First_Component (Rec); - while Present (Comp) loop - Check_Component_Storage_Order - (Encl_Type => Rec, - Comp => Comp, - ADC => SSO_ADC, - Comp_ADC_Present => Comp_ADC_Present); - SSO_ADC_Component := SSO_ADC_Component or Comp_ADC_Present; - Next_Component (Comp); - end loop; - end; + Set_SSO_From_Default (Rec); + + -- Check consistent attribute setting on component types + + declare + Comp_ADC_Present : Boolean; + begin + Comp := First_Component (Rec); + while Present (Comp) loop + Check_Component_Storage_Order + (Encl_Type => Rec, + Comp => Comp, + ADC => SSO_ADC, + Comp_ADC_Present => Comp_ADC_Present); + SSO_ADC_Component := SSO_ADC_Component or Comp_ADC_Present; + Next_Component (Comp); + end loop; + end; - -- Now deal with reverse storage order/bit order issues + -- Now deal with reverse storage order/bit order issues - if Present (SSO_ADC) then + if Present (SSO_ADC) then - -- Check compatibility of Scalar_Storage_Order with Bit_Order, if - -- the former is specified. + -- Check compatibility of Scalar_Storage_Order with Bit_Order, + -- if the former is specified. - if Reverse_Bit_Order (Rec) /= Reverse_Storage_Order (Rec) then + if Reverse_Bit_Order (Rec) /= Reverse_Storage_Order (Rec) then - -- Note: report error on Rec, not on SSO_ADC, as ADC may apply - -- to some ancestor type. + -- Note: report error on Rec, not on SSO_ADC, as ADC may + -- apply to some ancestor type. - Error_Msg_Sloc := Sloc (SSO_ADC); - Error_Msg_N - ("scalar storage order for& specified# inconsistent with " - & "bit order", Rec); - end if; + Error_Msg_Sloc := Sloc (SSO_ADC); + Error_Msg_N + ("scalar storage order for& specified# inconsistent with " + & "bit order", Rec); + end if; - -- Warn if there is an Scalar_Storage_Order attribute definition - -- clause but no component clause, no component that itself has - -- such an attribute definition, and no pragma Pack. + -- Warn if there is a Scalar_Storage_Order attribute definition + -- clause but no component clause, no component that itself has + -- such an attribute definition, and no pragma Pack. - if not (Placed_Component - or else - SSO_ADC_Component - or else - Is_Packed (Rec)) - then - Error_Msg_N - ("??scalar storage order specified but no component clause", - SSO_ADC); + if not (Placed_Component + or else + SSO_ADC_Component + or else + Is_Packed (Rec)) + then + Error_Msg_N + ("??scalar storage order specified but no component " + & "clause", SSO_ADC); + end if; end if; end if; -- 2.30.2