diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2018-07-17 08:10:04 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-07-17 08:10:04 +0000 |
commit | 69720717c143a9dc77d4c52dd5e2f19858425fa8 (patch) | |
tree | 58f1e9f5f651c6376b9924d9b982df13c26b31c8 /gcc/ada/gcc-interface/trans.c | |
parent | 123483ca18f7d6d0c5b28230e826a44a7cf4f111 (diff) | |
download | gcc-69720717c143a9dc77d4c52dd5e2f19858425fa8.zip gcc-69720717c143a9dc77d4c52dd5e2f19858425fa8.tar.gz gcc-69720717c143a9dc77d4c52dd5e2f19858425fa8.tar.bz2 |
[Ada] Type mismatch warning for imported C++ class
2018-07-17 Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* gcc-interface/ada-tree.h (TYPE_RETURN_BY_DIRECT_REF_P): Define for
METHOD_TYPE too.
(TYPE_RETURN_UNCONSTRAINED_P): Likewise.
(TYPE_CI_CO_LIST): Likewise.
* gcc-interface/gigi.h (is_cplusplus_method): Delete.
(fntype_same_flags_p): Adjust comment.
* gcc-interface/decl.c (Has_Thiscall_Convention): Delete.
(gnat_to_gnu_entity) <E_Subprogram_Type>: Do not set the "thiscall"
attribute directly.
(is_cplusplus_method): Make static and adjust head comment.
(gnat_to_gnu_param): Return a pointer for the "this" parameter of
C++ constructors.
(gnat_to_gnu_subprog_type): Turn imported C++ constructors into their
callable form. Generate a METHOD_TYPE node for imported C++ methods.
Set param_list at the very end of the processing.
(substitute_in_type) <METHOD_TYPE>: New case.
* gcc-interface/misc.c (gnat_print_type) <METHOD_TYPE>: Likewise.
(gnat_type_hash_eq): Accept METHOD_TYPE.
* gcc-interface/trans.c (Identifier_to_gnu): Deal with METHOD_TYPE.
(Attribute_to_gnu): Likewise.
(Call_to_gnu): Likewise.
(process_freeze_entity): Likewise.
* gcc-interface/utils.c (create_subprog_decl): Adjust head comment.
(fntype_same_flags_p): Likewise.
From-SVN: r262792
Diffstat (limited to 'gcc/ada/gcc-interface/trans.c')
-rw-r--r-- | gcc/ada/gcc-interface/trans.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index effd281..31e098a 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -1226,7 +1226,7 @@ Identifier_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p) of a discriminated type whose full view can be elaborated statically, to avoid problematic conversions to the nominal subtype. But remove any padding from the resulting type. */ - if (TREE_CODE (TREE_TYPE (gnu_result)) == FUNCTION_TYPE + if (FUNC_OR_METHOD_TYPE_P (TREE_TYPE (gnu_result)) || Is_Constr_Subt_For_UN_Aliased (gnat_temp_type) || (Ekind (gnat_temp) == E_Constant && Present (Full_View (gnat_temp)) @@ -1730,15 +1730,14 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) since it can use a special calling convention on some platforms, which cannot be propagated to the access type. */ else if (attribute == Attr_Access - && Nkind (gnat_prefix) == N_Identifier - && is_cplusplus_method (Entity (gnat_prefix))) + && TREE_CODE (TREE_TYPE (gnu_prefix)) == METHOD_TYPE) post_error ("access to C++ constructor or member function not allowed", gnat_node); /* 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 (FUNC_OR_METHOD_TYPE_P (TREE_TYPE (gnu_prefix))) { gnu_expr = remove_conversions (gnu_result, false); @@ -4283,7 +4282,7 @@ Call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target, Node_Id gnat_actual; bool sync; - gcc_assert (TREE_CODE (gnu_subprog_type) == FUNCTION_TYPE); + gcc_assert (FUNC_OR_METHOD_TYPE_P (gnu_subprog_type)); /* If we are calling a stubbed function, raise Program_Error, but Elaborate all our args first. */ @@ -8743,7 +8742,7 @@ process_freeze_entity (Node_Id gnat_node) if (gnu_old && ((TREE_CODE (gnu_old) == FUNCTION_DECL && (kind == E_Function || kind == E_Procedure)) - || (TREE_CODE (TREE_TYPE (gnu_old)) == FUNCTION_TYPE + || (FUNC_OR_METHOD_TYPE_P (TREE_TYPE (gnu_old)) && kind == E_Subprogram_Type))) return; |