]> gcc.gnu.org Git - gcc.git/commitdiff
ada: Add kludge for quirk of ancient 32-bit ABIs to previous change
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 23 Aug 2024 15:06:00 +0000 (17:06 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 3 Sep 2024 08:16:54 +0000 (10:16 +0200)
Some ancient 32-bit ABIs, most notably that of x86/Linux, misalign double
scalars in record types, so comparing DECL_ALIGN with TYPE_ALIGN directly
may give the wrong answer for them.

gcc/ada/

* gcc-interface/trans.cc (addressable_p) <COMPONENT_REF>: Add kludge
to cope with ancient 32-bit ABIs.

gcc/ada/gcc-interface/trans.cc

index fadd6b483d5a844454c87964a815693d6de45a07..c99b06670d58b316b63c6f7bf307971ae7aad37b 100644 (file)
@@ -10294,8 +10294,20 @@ addressable_p (tree gnu_expr, tree gnu_type)
                   check the alignment of the containing record, as it is
                   guaranteed to be not smaller than that of its most
                   aligned field that is not a bit-field.  */
-               && DECL_ALIGN (TREE_OPERAND (gnu_expr, 1))
-                  >= TYPE_ALIGN (TREE_TYPE (gnu_expr)))
+               && (DECL_ALIGN (TREE_OPERAND (gnu_expr, 1))
+                   >= TYPE_ALIGN (TREE_TYPE (gnu_expr))
+#ifdef TARGET_ALIGN_DOUBLE
+                  /* Cope with the misalignment of doubles in records for
+                     ancient 32-bit ABIs like that of x86/Linux.  */
+                  || (DECL_ALIGN (TREE_OPERAND (gnu_expr, 1)) == 32
+                      && TYPE_ALIGN (TREE_TYPE (gnu_expr)) == 64
+                      && !TARGET_ALIGN_DOUBLE
+#ifdef TARGET_64BIT
+                      && !TARGET_64BIT
+#endif
+                     )
+#endif
+                      ))
               /* The field of a padding record is always addressable.  */
               || TYPE_IS_PADDING_P (TREE_TYPE (TREE_OPERAND (gnu_expr, 0))))
              && addressable_p (TREE_OPERAND (gnu_expr, 0), NULL_TREE));
This page took 0.070895 seconds and 5 git commands to generate.