diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2024-08-26 11:16:41 +0200 |
---|---|---|
committer | Marc Poulhiès <dkm@gcc.gnu.org> | 2024-09-05 10:10:13 +0200 |
commit | 65186cab1d3c9b0dad17dc0536586bec634b93f3 (patch) | |
tree | 16884f4977e7740ac52052b61076ce3bcdf982b3 /gcc/ada/gcc-interface | |
parent | 72c6938f29cbeddb3220720e68add4cf09ffd794 (diff) | |
download | gcc-65186cab1d3c9b0dad17dc0536586bec634b93f3.zip gcc-65186cab1d3c9b0dad17dc0536586bec634b93f3.tar.gz gcc-65186cab1d3c9b0dad17dc0536586bec634b93f3.tar.bz2 |
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) <COMPONENT_REF>: Add bypass
for internal fields on strict-alignment platforms.
Diffstat (limited to 'gcc/ada/gcc-interface')
-rw-r--r-- | gcc/ada/gcc-interface/trans.cc | 11 |
1 files changed, 8 insertions, 3 deletions
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)); |