diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2017-09-06 11:44:29 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2017-09-06 11:44:29 +0200 |
commit | 8489c2956a08a7397d80cc21f67c1a1064c14cdc (patch) | |
tree | 3927435d4fc7bbbdc970057a5a4e68969549dda0 /gcc/ada/sem_ch3.adb | |
parent | dd89dddff4f63572408c3bcd602eb8773288179c (diff) | |
download | gcc-8489c2956a08a7397d80cc21f67c1a1064c14cdc.zip gcc-8489c2956a08a7397d80cc21f67c1a1064c14cdc.tar.gz gcc-8489c2956a08a7397d80cc21f67c1a1064c14cdc.tar.bz2 |
[multiple changes]
2017-09-06 Eric Botcazou <ebotcazou@adacore.com>
* ali.ads (ALIs_Record): Add No_Component_Reordering component.
(No_Component_Reordering_Specified): New switch.
* ali.adb (Initialize_ALI): Set No_Component_Reordering_Specified.
(Scan_ALI): Set No_Component_Reordering and deal with NC marker.
* bcheck.adb (Check_Consistent_No_Component_Reordering):
New check.
(Check_Configuration_Consistency): Invoke it.
* debug.adb (d.r): Toggle the effect of the switch.
(d.v): Change to no-op.
* einfo.ads (Has_Complex_Representation):
Restrict to record types.
(No_Reordering): New alias for Flag239.
(OK_To_Reorder_Components): Delete.
(No_Reordering): Declare.
(Set_No_Reordering): Likewise.
(OK_To_Reorder_Components): Delete.
(Set_OK_To_Reorder_Components): Likewise.
* einfo.adb (Has_Complex_Representation): Expect record types.
(No_Reordering): New function.
(OK_To_Reorder_Components): Delete.
(Set_Has_Complex_Representation): Expect base record types.
(Set_No_Reordering): New procedure.
(Set_OK_To_Reorder_Components): Delete.
(Write_Entity_Flags): Adjust to above change.
* fe.h (Debug_Flag_Dot_R): New macro and declaration.
* freeze.adb (Freeze_Record_Type): Remove conditional code setting
OK_To_Reorder_Components on record types with convention Ada.
* lib-writ.adb (Write_ALI): Deal with NC marker.
* opt.ads (No_Component_Reordering): New flag.
(No_Component_Reordering_Config): Likewise.
(Config_Switches_Type): Add No_Component_Reordering component.
* opt.adb (Register_Opt_Config_Switches): Copy
No_Component_Reordering onto No_Component_Reordering_Config.
(Restore_Opt_Config_Switches): Restore No_Component_Reordering.
(Save_Opt_Config_Switches): Save No_Component_Reordering.
(Set_Opt_Config_Switches): Set No_Component_Reordering.
* par-prag.adb (Prag): Deal with Pragma_No_Component_Reordering.
* sem_ch3.adb (Analyze_Private_Extension_Declaration): Also set the
No_Reordering flag from the default.
(Build_Derived_Private_Type): Likewise.
(Build_Derived_Record_Type): Likewise. Then inherit it
for untagged types and clean up handling of similar flags.
(Record_Type_Declaration): Likewise.
* sem_ch13.adb (Same_Representation): Deal with No_Reordering and
remove redundant test on Is_Tagged_Type.
* sem_prag.adb (Analyze_Pragma): Handle No_Component_Reordering.
(Sig_Flags): Likewise.
* snames.ads-tmpl (Name_No_Component_Reordering): New name.
(Pragma_Id): Add Pragma_No_Component_Reordering value.
* warnsw.adb (Set_GNAT_Mode_Warnings): Enable -gnatw.q as well.
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Type>:
Copy the layout of the parent type only if the No_Reordering
settings match.
(components_to_record): Reorder record types with
convention Ada by default unless No_Reordering is set or -gnatd.r
is specified and do not warn if No_Reordering is set in GNAT mode.
2017-09-06 Ed Schonberg <schonberg@adacore.com>
* sem_util.ads, sem_util.adb (Check_Previous_Null_Procedure):
new predicate to reject declarations that can be completions,
when there is a visible prior homograph that is a null procedure.
* sem_ch6.adb (Analyze_Null_Procedure): use it.
* sem_ch8.adb (Analyze_Subprogram_Renaming): ditto.
2017-09-06 Thomas Quinot <quinot@adacore.com>
* s-regpat.adb (Compile.Parse_Literal): Fix handling of literal
run of 253 characters or more.
From-SVN: r251760
Diffstat (limited to 'gcc/ada/sem_ch3.adb')
-rw-r--r-- | gcc/ada/sem_ch3.adb | 71 |
1 files changed, 28 insertions, 43 deletions
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 6fbcea27..93a2c89 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -5015,6 +5015,7 @@ package body Sem_Ch3 is Set_Ekind (T, E_Record_Type_With_Private); Init_Size_Align (T); Set_Default_SSO (T); + Set_No_Reordering (T, No_Component_Reordering); Set_Etype (T, Parent_Base); Propagate_Concurrent_Flags (T, Parent_Base); @@ -7679,6 +7680,7 @@ package body Sem_Ch3 is Set_Ekind (Full_Der, E_Record_Type); Set_Is_Underlying_Record_View (Full_Der); Set_Default_SSO (Full_Der); + Set_No_Reordering (Full_Der, No_Component_Reordering); Analyze (Decl); @@ -8478,6 +8480,7 @@ package body Sem_Ch3 is Type_Def := N; Set_Ekind (Derived_Type, E_Record_Type_With_Private); Set_Default_SSO (Derived_Type); + Set_No_Reordering (Derived_Type, No_Component_Reordering); else Type_Def := Type_Definition (N); @@ -8492,6 +8495,7 @@ package body Sem_Ch3 is if Present (Record_Extension_Part (Type_Def)) then Set_Ekind (Derived_Type, E_Record_Type); Set_Default_SSO (Derived_Type); + Set_No_Reordering (Derived_Type, No_Component_Reordering); -- Create internal access types for components with anonymous -- access types. @@ -9112,60 +9116,45 @@ package body Sem_Ch3 is Set_Has_Primitive_Operations (Derived_Type, Has_Primitive_Operations (Parent_Base)); - -- Fields inherited from the Parent_Base in the non-private case + -- Set fields for private derived types - if Ekind (Derived_Type) = E_Record_Type then - Set_Has_Complex_Representation - (Derived_Type, Has_Complex_Representation (Parent_Base)); + if Is_Private_Type (Derived_Type) then + Set_Depends_On_Private (Derived_Type, True); + Set_Private_Dependents (Derived_Type, New_Elmt_List); end if; - -- Fields inherited from the Parent_Base for record types + -- Inherit fields for non-private types. If this is the completion of a + -- derivation from a private type, the parent itself is private and the + -- attributes come from its full view, which must be present. if Is_Record_Type (Derived_Type) then declare Parent_Full : Entity_Id; begin - -- Ekind (Parent_Base) is not necessarily E_Record_Type since - -- Parent_Base can be a private type or private extension. Go - -- to the full view here to get the E_Record_Type specific flags. - - if Present (Full_View (Parent_Base)) then + if Is_Private_Type (Parent_Base) + and then not Is_Record_Type (Parent_Base) + then Parent_Full := Full_View (Parent_Base); else Parent_Full := Parent_Base; end if; - Set_OK_To_Reorder_Components - (Derived_Type, OK_To_Reorder_Components (Parent_Full)); - end; - end if; - - -- Set fields for private derived types - - if Is_Private_Type (Derived_Type) then - Set_Depends_On_Private (Derived_Type, True); - Set_Private_Dependents (Derived_Type, New_Elmt_List); - - -- Inherit fields from non private record types. If this is the - -- completion of a derivation from a private type, the parent itself - -- is private, and the attributes come from its full view, which must - -- be present. - - else - if Is_Private_Type (Parent_Base) - and then not Is_Record_Type (Parent_Base) - then Set_Component_Alignment - (Derived_Type, Component_Alignment (Full_View (Parent_Base))); + (Derived_Type, Component_Alignment (Parent_Full)); Set_C_Pass_By_Copy - (Derived_Type, C_Pass_By_Copy (Full_View (Parent_Base))); - else - Set_Component_Alignment - (Derived_Type, Component_Alignment (Parent_Base)); - Set_C_Pass_By_Copy - (Derived_Type, C_Pass_By_Copy (Parent_Base)); - end if; + (Derived_Type, C_Pass_By_Copy (Parent_Full)); + Set_Has_Complex_Representation + (Derived_Type, Has_Complex_Representation (Parent_Full)); + + -- For untagged types, inherit the layout by default to avoid + -- costly changes of representation for type conversions. + + if not Is_Tagged then + Set_Is_Packed (Derived_Type, Is_Packed (Parent_Full)); + Set_No_Reordering (Derived_Type, No_Reordering (Parent_Full)); + end if; + end; end if; -- Set fields for tagged types @@ -9270,11 +9259,6 @@ package body Sem_Ch3 is end if; end; end if; - - else - Set_Is_Packed (Derived_Type, Is_Packed (Parent_Base)); - Set_Has_Non_Standard_Rep - (Derived_Type, Has_Non_Standard_Rep (Parent_Base)); end if; -- STEP 4: Inherit components from the parent base and constrain them. @@ -21540,6 +21524,7 @@ package body Sem_Ch3 is Set_Interfaces (T, No_Elist); Set_Stored_Constraint (T, No_Elist); Set_Default_SSO (T); + Set_No_Reordering (T, No_Component_Reordering); -- Normal case |