aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2019-09-23 08:10:03 +0000
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2019-09-23 08:10:03 +0000
commit30b4c412c454a4e476eb41eb11b77fbcf3909e76 (patch)
treeea8dc74f96fb350a78a8c397747f1fed37f5adee
parent0110ab63c006fe8f1a86142cd6e86d5534f8bc8e (diff)
* gcc-interface/trans.c (Attribute_to_gnu): Test Can_Use_Internal_Rep
on the underlying type of the node. (Call_to_gnu): Likewise with the type of the prefix. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@276044 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/gcc-interface/trans.c48
2 files changed, 29 insertions, 25 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 71ee1904cf5..5c39dbc6328 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,9 @@
+2019-09-23 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gcc-interface/trans.c (Attribute_to_gnu): Test Can_Use_Internal_Rep
+ on the underlying type of the node.
+ (Call_to_gnu): Likewise with the type of the prefix.
+
2019-09-06 Iain Sandoe <iain@sandoe.co.uk>
Backport from mainline.
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
index cccbcaa176e..ec87ef88598 100644
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -1706,32 +1706,29 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute)
/* For other address attributes applied to a nested function,
find an inner ADDR_EXPR and annotate it so that we can issue
a useful warning with -Wtrampolines. */
- else if (TREE_CODE (TREE_TYPE (gnu_prefix)) == FUNCTION_TYPE)
+ else if (TREE_CODE (TREE_TYPE (gnu_prefix)) == FUNCTION_TYPE
+ && (gnu_expr = remove_conversions (gnu_result, false))
+ && TREE_CODE (gnu_expr) == ADDR_EXPR
+ && decl_function_context (TREE_OPERAND (gnu_expr, 0)))
{
- gnu_expr = remove_conversions (gnu_result, false);
+ set_expr_location_from_node (gnu_expr, gnat_node);
- if (TREE_CODE (gnu_expr) == ADDR_EXPR
- && decl_function_context (TREE_OPERAND (gnu_expr, 0)))
- {
- set_expr_location_from_node (gnu_expr, gnat_node);
-
- /* Also check the inlining status. */
- check_inlining_for_nested_subprog (TREE_OPERAND (gnu_expr, 0));
-
- /* Moreover, for 'Access or 'Unrestricted_Access with non-
- foreign-compatible representation, mark the ADDR_EXPR so
- that we can build a descriptor instead of a trampoline. */
- if ((attribute == Attr_Access
- || attribute == Attr_Unrestricted_Access)
- && targetm.calls.custom_function_descriptors > 0
- && Can_Use_Internal_Rep (Etype (gnat_node)))
- FUNC_ADDR_BY_DESCRIPTOR (gnu_expr) = 1;
-
- /* Otherwise, we need to check that we are not violating the
- No_Implicit_Dynamic_Code restriction. */
- else if (targetm.calls.custom_function_descriptors != 0)
- Check_Implicit_Dynamic_Code_Allowed (gnat_node);
- }
+ /* Also check the inlining status. */
+ check_inlining_for_nested_subprog (TREE_OPERAND (gnu_expr, 0));
+
+ /* Moreover, for 'Access or 'Unrestricted_Access with non-
+ foreign-compatible representation, mark the ADDR_EXPR so
+ that we can build a descriptor instead of a trampoline. */
+ if ((attribute == Attr_Access
+ || attribute == Attr_Unrestricted_Access)
+ && targetm.calls.custom_function_descriptors > 0
+ && Can_Use_Internal_Rep (Underlying_Type (Etype (gnat_node))))
+ FUNC_ADDR_BY_DESCRIPTOR (gnu_expr) = 1;
+
+ /* Otherwise, we need to check that we are not violating the
+ No_Implicit_Dynamic_Code restriction. */
+ else if (targetm.calls.custom_function_descriptors != 0)
+ Check_Implicit_Dynamic_Code_Allowed (gnat_node);
}
break;
@@ -4290,7 +4287,8 @@ Call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target,
/* If the access type doesn't require foreign-compatible representation,
be prepared for descriptors. */
if (targetm.calls.custom_function_descriptors > 0
- && Can_Use_Internal_Rep (Etype (Prefix (Name (gnat_node)))))
+ && Can_Use_Internal_Rep
+ (Underlying_Type (Etype (Prefix (Name (gnat_node))))))
by_descriptor = true;
}
else if (Nkind (Name (gnat_node)) == N_Attribute_Reference)