]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Reject misalignment of objects with address clause
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 30 Apr 2026 11:08:17 +0000 (13:08 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 2 Jun 2026 08:42:33 +0000 (10:42 +0200)
Misaligned objects are meant to be rejected universally by the compiler.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Validate
a known alignment on the object even if there is an address clause.

gcc/ada/gcc-interface/decl.cc

index 50a065d2dea65a3789dcffe51ce410951d9a4dc9..3a14f226f0eb53427b8aee05f6ac1c1986135f04 100644 (file)
@@ -814,12 +814,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
          }
 
        /* If an alignment is specified, use it if valid.  Note that exceptions
-          are objects but don't have an alignment and there is also no point in
-          setting it for an address clause, since the final type of the object
-          will be a reference type.  */
-       if (Known_Alignment (gnat_entity)
-           && kind != E_Exception
-           && No (Address_Clause (gnat_entity)))
+          are objects but don't have an alignment.  */
+       if (Known_Alignment (gnat_entity) && kind != E_Exception)
          align = validate_alignment (Alignment (gnat_entity), gnat_entity,
                                      TYPE_ALIGN (gnu_type));