From: Eric Botcazou Date: Mon, 23 Sep 2019 08:08:08 +0000 (+0000) Subject: trans.c (Attribute_to_gnu): Test Can_Use_Internal_Rep on the underlying type of the... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ef5a9557bdfeef1d7941ec52702a25f2de9abcdc;p=gcc.git trans.c (Attribute_to_gnu): Test Can_Use_Internal_Rep on the underlying type of the node. * 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. From-SVN: r276041 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 79e63267cc1..f74e8bb3524 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2019-09-23 Eric Botcazou + + * 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-23 Eric Botcazou * gcc-interface/decl.c (components_to_record): Do not reorder fields diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index fe02dc4d64f..1af477f9924 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -2254,32 +2254,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 (FUNC_OR_METHOD_TYPE_P (TREE_TYPE (gnu_prefix))) + else if (FUNC_OR_METHOD_TYPE_P (TREE_TYPE (gnu_prefix)) + && (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; @@ -5111,7 +5108,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)