From 1dcdd961c5cdce6e850ff20b1954919972553920 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Mon, 16 Dec 2019 10:34:47 +0000 Subject: [PATCH] [Ada] Remove new strict-alignment check added by AI12-0001 2019-12-16 Eric Botcazou gcc/ada/ * freeze.adb (Check_Strict_Alignment): Remove new check on Has_Aliased_Components for array types. From-SVN: r279433 --- gcc/ada/ChangeLog | 5 +++++ gcc/ada/freeze.adb | 30 ++++++++++++++---------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 5533c1cca53..8f5c089bf87 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2019-12-16 Eric Botcazou + + * freeze.adb (Check_Strict_Alignment): Remove new check on + Has_Aliased_Components for array types. + 2019-12-16 Ed Schonberg * sem_ch4.adb (Try_Container_Indexing): In the case of a derived diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 36cf63cad16..0312ca704aa 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -1614,24 +1614,22 @@ package body Freeze is Set_Strict_Alignment (E); elsif Is_Array_Type (E) then - if Has_Aliased_Components (E) - or else Strict_Alignment (Component_Type (E)) - then - Set_Strict_Alignment (E); - end if; + Set_Strict_Alignment (E, Strict_Alignment (Component_Type (E))); - elsif Is_Record_Type (E) then - -- ??? If the type has convention C_Pass_By_Copy, we consider - -- that it may be packed even if it contains aliased parts. - -- Such types are very unlikely to be misaligned in practice - -- and this makes the compiler accept dubious representation - -- clauses used in Florist on types containing arrays with - -- aliased components. - - if C_Pass_By_Copy (E) then - return; - end if; + -- ??? AI12-001: Any component of a packed type that contains an + -- aliased part must be aligned according to the alignment of its + -- subtype (RM 13.2(7)). This means that the following test: + + -- if Has_Aliased_Components (E) then + -- Set_Strict_Alignment (E); + -- end if; + -- should be implemented here. Unfortunately it would break Florist, + -- which has the bad habit of overaligning all the types it declares + -- on 32-bit platforms. Other legacy codebases could also be affected + -- because this check has historically been missing in GNAT. + + elsif Is_Record_Type (E) then Comp := First_Component (E); while Present (Comp) loop if not Is_Type (Comp) -- 2.30.2