aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.come>2024-11-11 11:16:26 +0100
committerMarc Poulhiès <dkm@gcc.gnu.org>2024-11-26 10:49:36 +0100
commitae7c0475f108f14cabcc1613df449670b1e9d1a2 (patch)
tree9a7f7a9c46059f9fb7a181d2da2e4f82b41237fb /gcc/ada/gcc-interface
parent84d8a383c9fe80bd9c4e364505247ef025e1c2b6 (diff)
downloadgcc-ae7c0475f108f14cabcc1613df449670b1e9d1a2.zip
gcc-ae7c0475f108f14cabcc1613df449670b1e9d1a2.tar.gz
gcc-ae7c0475f108f14cabcc1613df449670b1e9d1a2.tar.bz2
ada: Do not use ATTR_ADDR_EXPR for 'Unrestricted_Access
Unlike for 'Access or 'Unchecked_Access, the Attribute_to_gnu routine passes ATTR_ADDR_EXPR to build_unary_op for 'Unrestricted_Access, which causes the processing done in build_unary_op to flatten the reference, in particular to remove all intermediate (view) conversions, which may be problematic for the SUBSTITUTE_PLACEHOLDER_IN_EXPR machinery. gcc/ada/ChangeLog: * gcc-interface/trans.cc (Attribute_to_gnu) <Attr_Access>: Do not pass ATTR_ADDR_EXPR to build_unary_op for 'Unrestricted_Access.
Diffstat (limited to 'gcc/ada/gcc-interface')
-rw-r--r--gcc/ada/gcc-interface/trans.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
index 5d971c1..3aa4125 100644
--- a/gcc/ada/gcc-interface/trans.cc
+++ b/gcc/ada/gcc-interface/trans.cc
@@ -1840,10 +1840,15 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p,
gcc_assert (TREE_CODE (gnu_prefix) != TYPE_DECL);
gnu_result_type = get_unpadded_type (Etype (gnat_node));
+
+ /* We used to pass ATTR_ADDR_EXPR for Attr_Unrestricted_Access too, but
+ the processing done in build_unary_op for it flattens the reference,
+ in particular removes all intermediate (view) conversions, which may
+ cause SUBSTITUTE_PLACEHOLDER_IN_EXPR to fail to substitute in the
+ bounds of a fat pointer returned for Attr_Unrestricted_Access. */
gnu_result
- = build_unary_op (((attribute == Attr_Address
- || attribute == Attr_Unrestricted_Access)
- && !Must_Be_Byte_Aligned (gnat_node))
+ = build_unary_op (attribute == Attr_Address
+ && !Must_Be_Byte_Aligned (gnat_node)
? ATTR_ADDR_EXPR : ADDR_EXPR,
gnu_result_type, gnu_prefix);