From 65186cab1d3c9b0dad17dc0536586bec634b93f3 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Mon, 26 Aug 2024 11:16:41 +0200 Subject: ada: Add bypass for internal fields on strict-alignment platforms This is required to support misalignment of tagged types in legacy code. gcc/ada/ * gcc-interface/trans.cc (addressable_p) : Add bypass for internal fields on strict-alignment platforms. --- gcc/ada/gcc-interface/trans.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc index 9e9f5f8..92e0006 100644 --- a/gcc/ada/gcc-interface/trans.cc +++ b/gcc/ada/gcc-interface/trans.cc @@ -10295,9 +10295,14 @@ addressable_p (tree gnu_expr, tree gnu_type) is guaranteed to be not smaller than that of its most aligned field that is not a bit-field. However, we need to cope with quirks of ABIs that may misalign fields. */ - && DECL_ALIGN (TREE_OPERAND (gnu_expr, 1)) - >= default_field_alignment (TREE_OPERAND (gnu_expr, 1), - TREE_TYPE (gnu_expr))) + && (DECL_ALIGN (TREE_OPERAND (gnu_expr, 1)) + >= default_field_alignment (TREE_OPERAND (gnu_expr, 1), + TREE_TYPE (gnu_expr)) + /* We do not enforce this on strict-alignment platforms for + internal fields in order to keep supporting misalignment + of tagged types in legacy code. */ + || (!STRICT_ALIGNMENT + && DECL_INTERNAL_P (TREE_OPERAND (gnu_expr, 1))))) /* 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)); -- cgit v1.1