https://gcc.gnu.org/g:40b0325ba5b779e36d24f61b72faf2d0450671c4
commit r16-5233-g40b0325ba5b779e36d24f61b72faf2d0450671c4 Author: Eric Botcazou <[email protected]> Date: Thu Oct 23 19:20:49 2025 +0200 ada: Fix ancient bug in pragma Suppress (Alignment_Check) The recent change that streamlined the implementation of alignment checks has uncovered an ancient bug in the implementation of pragma Suppress on a specific object: pragma Suppress (Alignment_Check, A); The pragma would work only if placed before the address clause: A : Integer; pragma Suppress (Alignment_Check, A); for A'Address use ... but not if placed (just) after it: A : Integer; for A'Address use ... pragma Suppress (Alignment_Check, A); which seems unfriendly at best. gcc/ada/ChangeLog: * sem_prag.adb (Analyze_Pragma) <Process_Suppress_Unsuppress>: For Alignment_Check on a specific object with an address clause and no alignment clause, toggle the Check_Address_Alignment flag present on the address clause. Diff: --- gcc/ada/sem_prag.adb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 0ebf421fc96f..88558a354784 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -11995,6 +11995,26 @@ package body Sem_Prag is if Is_First_Subtype (E) and then Etype (E) /= E then Suppress_Unsuppress_Echeck (Etype (E), C); end if; + + -- For the alignment check of an object with an address clause, + -- we want the pragma to be taken into account even if it comes + -- after the address clause: + + -- A : Integer; + -- for A'Address use ... + -- pragma Suppress (Alignment_Check, A); + + -- When there is also an alignment clause, the check is generated + -- unconditionally, see Analyze_Attribute_Definition_Clause. + + if C = Alignment_Check + and then not Is_Type (E) + and then Present (Address_Clause (E)) + and then No (Alignment_Clause (E)) + then + Set_Check_Address_Alignment + (Address_Clause (E), not Suppress_Case); + end if; end Suppress_Unsuppress_Echeck; -- Start of processing for Process_Suppress_Unsuppress
