From: Paolo Carlini Date: Fri, 10 May 2019 17:57:27 +0000 (+0000) Subject: call.c (build_call_a): Use FUNC_OR_METHOD_TYPE_P. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7bdc7e0661dae954b919416882d5a9064a202614;p=gcc.git call.c (build_call_a): Use FUNC_OR_METHOD_TYPE_P. 2019-05-10 Paolo Carlini * call.c (build_call_a): Use FUNC_OR_METHOD_TYPE_P. * cp-gimplify.c (cp_fold): Likewise. * cp-objcp-common.c (cp_type_dwarf_attribute): Likewise. * cp-tree.h (TYPE_OBJ_P, TYPE_PTROBV_P): Likewise. * cvt.c (perform_qualification_conversions): Likewise. * decl.c (grokdeclarator): Likewise. * decl2.c (build_memfn_type): Likewise. * mangle.c (canonicalize_for_substitution, write_type): Likewise. * parser.c (cp_parser_omp_declare_reduction): Likewise. * pt.c (check_explicit_specialization, uses_deducible_template_parms, check_cv_quals_for_unify, dependent_type_p_r): Likewise. * rtti.c (ptr_initializer): Likewise. * semantics.c (finish_asm_stmt, finish_offsetof, cp_check_omp_declare_reduction): Likewise. * tree.c (cp_build_qualified_type_real, cp_build_type_attribute_variant, cxx_type_hash_eq, cxx_copy_lang_qualifiers, cp_free_lang_data): Likewise. * typeck.c (structural_comptypes, convert_arguments, cp_build_addr_expr_1, unary_complex_lvalue, cp_build_c_cast, cp_build_modify_expr, comp_ptr_ttypes_real, type_memfn_rqual): Likewise. From-SVN: r271069 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a43001a1a11..4b245a2f604 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,27 @@ +2019-05-10 Paolo Carlini + + * call.c (build_call_a): Use FUNC_OR_METHOD_TYPE_P. + * cp-gimplify.c (cp_fold): Likewise. + * cp-objcp-common.c (cp_type_dwarf_attribute): Likewise. + * cp-tree.h (TYPE_OBJ_P, TYPE_PTROBV_P): Likewise. + * cvt.c (perform_qualification_conversions): Likewise. + * decl.c (grokdeclarator): Likewise. + * decl2.c (build_memfn_type): Likewise. + * mangle.c (canonicalize_for_substitution, write_type): Likewise. + * parser.c (cp_parser_omp_declare_reduction): Likewise. + * pt.c (check_explicit_specialization, uses_deducible_template_parms, + check_cv_quals_for_unify, dependent_type_p_r): Likewise. + * rtti.c (ptr_initializer): Likewise. + * semantics.c (finish_asm_stmt, finish_offsetof, + cp_check_omp_declare_reduction): Likewise. + * tree.c (cp_build_qualified_type_real, + cp_build_type_attribute_variant, cxx_type_hash_eq, + cxx_copy_lang_qualifiers, cp_free_lang_data): Likewise. + * typeck.c (structural_comptypes, convert_arguments, + cp_build_addr_expr_1, unary_complex_lvalue, cp_build_c_cast, + cp_build_modify_expr, comp_ptr_ttypes_real, type_memfn_rqual): + Likewise. + 2019-05-10 Marek Polacek PR c++/78010 - bogus -Wsuggest-override warning on final function. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 20db2974b56..2329c4cb43e 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -357,8 +357,7 @@ build_call_a (tree function, int n, tree *argarray) gcc_assert (TYPE_PTR_P (TREE_TYPE (function))); fntype = TREE_TYPE (TREE_TYPE (function)); - gcc_assert (TREE_CODE (fntype) == FUNCTION_TYPE - || TREE_CODE (fntype) == METHOD_TYPE); + gcc_assert (FUNC_OR_METHOD_TYPE_P (fntype)); result_type = TREE_TYPE (fntype); /* An rvalue has no cv-qualifiers. */ if (SCALAR_TYPE_P (result_type) || VOID_TYPE_P (result_type)) diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 26be1fd1522..7a243addb92 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -2324,8 +2324,7 @@ cp_fold (tree x) /* Cope with user tricks that amount to offsetof. */ if (op0 != error_mark_node - && TREE_CODE (TREE_TYPE (op0)) != FUNCTION_TYPE - && TREE_CODE (TREE_TYPE (op0)) != METHOD_TYPE) + && !FUNC_OR_METHOD_TYPE_P (TREE_TYPE (op0))) { tree val = get_base_address (op0); if (val diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c index bfd3fa6bf8d..a8f7db0854a 100644 --- a/gcc/cp/cp-objcp-common.c +++ b/gcc/cp/cp-objcp-common.c @@ -248,16 +248,14 @@ cp_type_dwarf_attribute (const_tree type, int attr) switch (attr) { case DW_AT_reference: - if ((TREE_CODE (type) == FUNCTION_TYPE - || TREE_CODE (type) == METHOD_TYPE) + if (FUNC_OR_METHOD_TYPE_P (type) && FUNCTION_REF_QUALIFIED (type) && !FUNCTION_RVALUE_QUALIFIED (type)) return 1; break; case DW_AT_rvalue_reference: - if ((TREE_CODE (type) == FUNCTION_TYPE - || TREE_CODE (type) == METHOD_TYPE) + if (FUNC_OR_METHOD_TYPE_P (type) && FUNCTION_REF_QUALIFIED (type) && FUNCTION_RVALUE_QUALIFIED (type)) return 1; diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index f253857b02a..7fb25a93e44 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4342,8 +4342,7 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter) #define TYPE_OBJ_P(NODE) \ (!TYPE_REF_P (NODE) \ && !VOID_TYPE_P (NODE) \ - && TREE_CODE (NODE) != FUNCTION_TYPE \ - && TREE_CODE (NODE) != METHOD_TYPE) + && !FUNC_OR_METHOD_TYPE_P (NODE)) /* Returns true if NODE is a pointer to an object. Keep these checks in ascending tree code order. */ @@ -4359,8 +4358,7 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter) void. Keep these checks in ascending tree code order. */ #define TYPE_PTROBV_P(NODE) \ (TYPE_PTR_P (NODE) \ - && !(TREE_CODE (TREE_TYPE (NODE)) == FUNCTION_TYPE \ - || TREE_CODE (TREE_TYPE (NODE)) == METHOD_TYPE)) + && !FUNC_OR_METHOD_TYPE_P (TREE_TYPE (NODE))) /* Returns true if NODE is a pointer to function type. */ #define TYPE_PTRFN_P(NODE) \ diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 3b8656c2a6b..b63a9ff6e98 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -1996,8 +1996,7 @@ perform_qualification_conversions (tree type, tree expr) bool tx_safe_fn_type_p (tree t) { - if (TREE_CODE (t) != FUNCTION_TYPE - && TREE_CODE (t) != METHOD_TYPE) + if (!FUNC_OR_METHOD_TYPE_P (t)) return false; return !!lookup_attribute ("transaction_safe", TYPE_ATTRIBUTES (t)); } diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 36014dc628e..300c2dbbbb1 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -11840,8 +11840,7 @@ grokdeclarator (const cp_declarator *declarator, } if (unqualified_id && TREE_CODE (unqualified_id) == TEMPLATE_ID_EXPR - && TREE_CODE (type) != FUNCTION_TYPE - && TREE_CODE (type) != METHOD_TYPE + && !FUNC_OR_METHOD_TYPE_P (type) && !variable_template_p (TREE_OPERAND (unqualified_id, 0))) { error ("template-id %qD used as a declarator", @@ -12003,8 +12002,7 @@ grokdeclarator (const cp_declarator *declarator, name); storage_class = sc_none; } - else if (TREE_CODE (type) == FUNCTION_TYPE - || TREE_CODE (type) == METHOD_TYPE) + else if (FUNC_OR_METHOD_TYPE_P (type)) { error_at (sloc, "function %qs cannot be declared %", name); @@ -12694,8 +12692,7 @@ grokdeclarator (const cp_declarator *declarator, declspecs->locations); } } - else if (TREE_CODE (type) == FUNCTION_TYPE - || TREE_CODE (type) == METHOD_TYPE) + else if (FUNC_OR_METHOD_TYPE_P (type)) { tree original_name; int publicp = 0; diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 6f23ee1cd3f..fb3b911fdd5 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -158,8 +158,7 @@ build_memfn_type (tree fntype, tree ctype, cp_cv_quals quals, if (fntype == error_mark_node || ctype == error_mark_node) return error_mark_node; - gcc_assert (TREE_CODE (fntype) == FUNCTION_TYPE - || TREE_CODE (fntype) == METHOD_TYPE); + gcc_assert (FUNC_OR_METHOD_TYPE_P (fntype)); cp_cv_quals type_quals = quals & ~TYPE_QUAL_RESTRICT; ctype = cp_build_qualified_type (ctype, type_quals); diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 4b2212349d6..c13dacbd05e 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -414,8 +414,7 @@ canonicalize_for_substitution (tree node) else node = cp_build_qualified_type (TYPE_MAIN_VARIANT (node), cp_type_quals (node)); - if (TREE_CODE (node) == FUNCTION_TYPE - || TREE_CODE (node) == METHOD_TYPE) + if (FUNC_OR_METHOD_TYPE_P (node)) { node = build_ref_qualified_type (node, type_memfn_rqual (orig)); tree r = canonical_eh_spec (TYPE_RAISES_EXCEPTIONS (orig)); @@ -2070,8 +2069,7 @@ write_type (tree type) t = cp_build_type_attribute_variant (t, attrs); } gcc_assert (t != type); - if (TREE_CODE (t) == FUNCTION_TYPE - || TREE_CODE (t) == METHOD_TYPE) + if (FUNC_OR_METHOD_TYPE_P (t)) { t = build_ref_qualified_type (t, type_memfn_rqual (type)); if (flag_noexcept_type) @@ -2102,8 +2100,7 @@ write_type (tree type) /* See through any typedefs. */ type = TYPE_MAIN_VARIANT (type); - if (TREE_CODE (type) == FUNCTION_TYPE - || TREE_CODE (type) == METHOD_TYPE) + if (FUNC_OR_METHOD_TYPE_P (type)) type = cxx_copy_lang_qualifiers (type, type_orig); /* According to the C++ ABI, some library classes are passed the diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 12beadf5096..5881d932fba 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -39646,8 +39646,7 @@ cp_parser_omp_declare_reduction (cp_parser *parser, cp_token *pragma_tok, || id_equal (orig_reduc_id, "max"))))) error_at (loc, "predeclared arithmetic type %qT in " "%<#pragma omp declare reduction%>", type); - else if (TREE_CODE (type) == FUNCTION_TYPE - || TREE_CODE (type) == METHOD_TYPE + else if (FUNC_OR_METHOD_TYPE_P (type) || TREE_CODE (type) == ARRAY_TYPE) error_at (loc, "function or array type %qT in " "%<#pragma omp declare reduction%>", type); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d6976e08690..08da94ae0c9 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -2906,8 +2906,7 @@ check_explicit_specialization (tree declarator, if ((specialization || member_specialization) /* This doesn't apply to variable templates. */ - && (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE - || TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE)) + && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (decl))) { tree t = TYPE_ARG_TYPES (TREE_TYPE (decl)); for (; t; t = TREE_CHAIN (t)) @@ -20667,8 +20666,7 @@ uses_deducible_template_parms (tree type) /* type (T) T() T(T) */ - if (TREE_CODE (type) == FUNCTION_TYPE - || TREE_CODE (type) == METHOD_TYPE) + if (FUNC_OR_METHOD_TYPE_P (type)) { if (uses_deducible_template_parms (TREE_TYPE (type))) return true; @@ -21646,8 +21644,7 @@ check_cv_quals_for_unify (int strict, tree arg, tree parm) It is ok when we're allowing additional CV qualifiers at the outer level [14.8.2.1]/3,1st bullet. */ if ((TYPE_REF_P (arg) - || TREE_CODE (arg) == FUNCTION_TYPE - || TREE_CODE (arg) == METHOD_TYPE) + || FUNC_OR_METHOD_TYPE_P (arg)) && (parm_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE))) return 0; @@ -25290,8 +25287,7 @@ dependent_type_p_r (tree type) (type))); else if (INDIRECT_TYPE_P (type)) return dependent_type_p (TREE_TYPE (type)); - else if (TREE_CODE (type) == FUNCTION_TYPE - || TREE_CODE (type) == METHOD_TYPE) + else if (FUNC_OR_METHOD_TYPE_P (type)) { tree arg_type; diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 3ca2b5e7b88..26dae3c3c1a 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -1015,8 +1015,7 @@ ptr_initializer (tinfo_s *ti, tree target) to = tx_unsafe_fn_variant (to); } if (flag_noexcept_type - && (TREE_CODE (to) == FUNCTION_TYPE - || TREE_CODE (to) == METHOD_TYPE) + && FUNC_OR_METHOD_TYPE_P (to) && TYPE_NOTHROW_P (to)) { flags |= 0x40; diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 93bd8fb8a17..1093cbef134 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1527,8 +1527,7 @@ finish_asm_stmt (int volatile_p, tree string, tree output_operands, || CP_TYPE_CONST_P (TREE_TYPE (operand)) /* Functions are not modifiable, even though they are lvalues. */ - || TREE_CODE (TREE_TYPE (operand)) == FUNCTION_TYPE - || TREE_CODE (TREE_TYPE (operand)) == METHOD_TYPE + || FUNC_OR_METHOD_TYPE_P (TREE_TYPE (operand)) /* If it's an aggregate and any field is const, then it is effectively const. */ || (CLASS_TYPE_P (TREE_TYPE (operand)) @@ -4141,8 +4140,7 @@ finish_offsetof (tree object_ptr, tree expr, location_t loc) TREE_OPERAND (expr, 2)); return error_mark_node; } - if (TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE - || TREE_CODE (TREE_TYPE (expr)) == METHOD_TYPE + if (FUNC_OR_METHOD_TYPE_P (TREE_TYPE (expr)) || TREE_TYPE (expr) == unknown_type_node) { while (TREE_CODE (expr) == COMPONENT_REF @@ -5538,8 +5536,7 @@ cp_check_omp_declare_reduction (tree udr) return; } } - else if (TREE_CODE (type) == FUNCTION_TYPE - || TREE_CODE (type) == METHOD_TYPE + else if (FUNC_OR_METHOD_TYPE_P (type) || TREE_CODE (type) == ARRAY_TYPE) { error_at (loc, "function or array type %qT in " diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 718eed349c6..ebc6cb6278d 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1308,8 +1308,7 @@ cp_build_qualified_type_real (tree type, (in CD1) we always ignore extra cv-quals on functions. */ if (type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE) && (TYPE_REF_P (type) - || TREE_CODE (type) == FUNCTION_TYPE - || TREE_CODE (type) == METHOD_TYPE)) + || FUNC_OR_METHOD_TYPE_P (type))) { if (TYPE_REF_P (type)) bad_quals |= type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE); @@ -4725,8 +4724,7 @@ cp_build_type_attribute_variant (tree type, tree attributes) tree new_type; new_type = build_type_attribute_variant (type, attributes); - if (TREE_CODE (new_type) == FUNCTION_TYPE - || TREE_CODE (new_type) == METHOD_TYPE) + if (FUNC_OR_METHOD_TYPE_P (new_type)) gcc_checking_assert (cxx_type_hash_eq (type, new_type)); /* Making a new main variant of a class type is broken. */ @@ -4741,8 +4739,7 @@ cp_build_type_attribute_variant (tree type, tree attributes) bool cxx_type_hash_eq (const_tree typea, const_tree typeb) { - gcc_assert (TREE_CODE (typea) == FUNCTION_TYPE - || TREE_CODE (typea) == METHOD_TYPE); + gcc_assert (FUNC_OR_METHOD_TYPE_P (typea)); if (type_memfn_rqual (typea) != type_memfn_rqual (typeb)) return false; @@ -4759,7 +4756,7 @@ tree cxx_copy_lang_qualifiers (const_tree typea, const_tree typeb) { tree type = CONST_CAST_TREE (typea); - if (TREE_CODE (type) == FUNCTION_TYPE || TREE_CODE (type) == METHOD_TYPE) + if (FUNC_OR_METHOD_TYPE_P (type)) type = build_cp_fntype_variant (type, type_memfn_rqual (typeb), TYPE_RAISES_EXCEPTIONS (typeb), TYPE_HAS_LATE_RETURN_TYPE (typeb)); @@ -5371,8 +5368,7 @@ cp_fix_function_decl_p (tree decl) void cp_free_lang_data (tree t) { - if (TREE_CODE (t) == METHOD_TYPE - || TREE_CODE (t) == FUNCTION_TYPE) + if (FUNC_OR_METHOD_TYPE_P (t)) { /* Default args are not interesting anymore. */ tree argtypes = TYPE_ARG_TYPES (t); diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 06f485a136b..fff45cc7d80 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -1262,8 +1262,7 @@ structural_comptypes (tree t1, tree t2, int strict) return false; /* Need to check this before TYPE_MAIN_VARIANT. FIXME function qualifiers should really change the main variant. */ - if (TREE_CODE (t1) == FUNCTION_TYPE - || TREE_CODE (t1) == METHOD_TYPE) + if (FUNC_OR_METHOD_TYPE_P (t1)) { if (type_memfn_rqual (t1) != type_memfn_rqual (t2)) return false; @@ -4037,8 +4036,7 @@ convert_arguments (tree typelist, vec **values, tree fndecl, if (type == 0 || !TYPE_REF_P (type)) { if (TREE_CODE (TREE_TYPE (val)) == ARRAY_TYPE - || TREE_CODE (TREE_TYPE (val)) == FUNCTION_TYPE - || TREE_CODE (TREE_TYPE (val)) == METHOD_TYPE) + || FUNC_OR_METHOD_TYPE_P (TREE_TYPE (val))) val = decay_conversion (val, complain); } @@ -6022,8 +6020,7 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue, tsubst_flags_t complain) /* Anything not already handled and not a true memory reference is an error. */ - if (TREE_CODE (argtype) != FUNCTION_TYPE - && TREE_CODE (argtype) != METHOD_TYPE) + if (!FUNC_OR_METHOD_TYPE_P (argtype)) { cp_lvalue_kind kind = lvalue_kind (arg); if (kind == clk_none) @@ -6600,8 +6597,7 @@ unary_complex_lvalue (enum tree_code code, tree arg) return arg; } - if (TREE_CODE (TREE_TYPE (arg)) == FUNCTION_TYPE - || TREE_CODE (TREE_TYPE (arg)) == METHOD_TYPE + if (FUNC_OR_METHOD_TYPE_P (TREE_TYPE (arg)) || TREE_CODE (arg) == OFFSET_REF) return NULL_TREE; @@ -7974,8 +7970,7 @@ cp_build_c_cast (tree type, tree expr, tsubst_flags_t complain) } } - if (TREE_CODE (type) == FUNCTION_TYPE - || TREE_CODE (type) == METHOD_TYPE) + if (FUNC_OR_METHOD_TYPE_P (type)) { if (complain & tf_error) error ("invalid cast to function type %qT", type); @@ -8328,8 +8323,7 @@ cp_build_modify_expr (location_t loc, tree lhs, enum tree_code modifycode, && (TREE_READONLY (lhs) || CP_TYPE_CONST_P (lhstype) /* Functions are not modifiable, even though they are lvalues. */ - || TREE_CODE (TREE_TYPE (lhs)) == FUNCTION_TYPE - || TREE_CODE (TREE_TYPE (lhs)) == METHOD_TYPE + || FUNC_OR_METHOD_TYPE_P (TREE_TYPE (lhs)) /* If it's an aggregate and any field is const, then it is effectively const. */ || (CLASS_TYPE_P (lhstype) @@ -9852,7 +9846,7 @@ comp_ptr_ttypes_real (tree to, tree from, int constp) /* Const and volatile mean something different for function types, so the usual checks are not appropriate. */ - if (TREE_CODE (to) != FUNCTION_TYPE && TREE_CODE (to) != METHOD_TYPE) + if (!FUNC_OR_METHOD_TYPE_P (to)) { if (!at_least_as_qualified_p (to, from)) return 0; @@ -10028,8 +10022,7 @@ cp_type_quals (const_tree type) cp_ref_qualifier type_memfn_rqual (const_tree type) { - gcc_assert (TREE_CODE (type) == FUNCTION_TYPE - || TREE_CODE (type) == METHOD_TYPE); + gcc_assert (FUNC_OR_METHOD_TYPE_P (type)); if (!FUNCTION_REF_QUALIFIED (type)) return REF_QUAL_NONE;