From patchwork Fri Nov 30 11:22:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1005895 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-491353-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="KHwVa3XB"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="1EW8kEh0"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 435sSy3cKJz9s9m for ; Fri, 30 Nov 2018 22:23:13 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=PrekN5PzJivYqqk1SCosUdlwGkGlOHyL9NyYoHdC95/UzQyqA7 aBlVOS1iiYaXQcplUGr5pUJ1/cgYfgJRw0/yALUeJJH4xyh8nvRMjXoTjB87tcuo hCnA84nZdvgCx6Nl0lIMxdWlg/Ciw1nUyYiHDw1x7HvxZcaGkyDTCskyE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=hIKhHGz8VfdYaapFr8G1IhK7GRo=; b=KHwVa3XBnbzOe6HS2qH9 lW6BiFcOb89P/KV2i6Ccn/jQ3GPW4pOBgW4Fz3Ic3pd5ujDX099X0rX85u7kNszf 589skgubnXOmwR8NJzYz6qjGjf0X6ylHoQBqEd4FOmvJrN7Tew7ZeRi+olVUHmEw v/FoGCAqP2yp3INXsN6lVlE= Received: (qmail 84268 invoked by alias); 30 Nov 2018 11:23:05 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 84256 invoked by uid 89); 30 Nov 2018 11:23:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=266503, typedefs, UD:tree.c, sk:gcc_che X-HELO: userp2120.oracle.com Received: from userp2120.oracle.com (HELO userp2120.oracle.com) (156.151.31.85) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 30 Nov 2018 11:22:58 +0000 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wAUBEngo024292; Fri, 30 Nov 2018 11:22:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=to : cc : from : subject : message-id : date : mime-version : content-type; s=corp-2018-07-02; bh=9Ita2s0B9bPJPMOM3CHfPUF5mDvTC6BLKiXyQ8+erj8=; b=1EW8kEh0PY0xY8uVAl766Vus1lPatUu0VO0bT64qbo/nqnMnOc1xfQN8d3XiVI3UlXRL OneSWtE7Kxl/l5FiL69itfhiTmXLlkUU+SRmI/lYtpVP3+9maAosb47bA0hZCiLFfudI QVkiuCwiYG6xovh8iSymdhn7WC1ttKTaKoOip+YU6QWg4FbsrdsgxdCteXfvRWA5akjY 3lBrTHDRDi7aUA84fo68JdNTEpP8iNWHbYwM/zhPO5dzYL9lrYwhJ7wTBj8ZZBsXZqlb 5f7Q1V6b2RCmJQArrt4Q86zJcXzjIls440e4xOASaWgUroZy5+1Y8GsIgzDEX1V28hwf Gg== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2nxy9rnrgw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Nov 2018 11:22:56 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wAUBMuYM009455 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Nov 2018 11:22:56 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wAUBMtBG008442; Fri, 30 Nov 2018 11:22:55 GMT Received: from [192.168.1.4] (/62.211.252.88) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 30 Nov 2018 03:22:54 -0800 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] Use FUNC_OR_METHOD_TYPE_P in cp/ Message-ID: Date: Fri, 30 Nov 2018 12:22:52 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, as promised in the exchange with Marek, I'm sending the straightforward patch, likely for next Stage 1. Tested x86_64-linux, as usual. Thanks, Paolo. //////////////////// 2018-11-30 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. Index: call.c =================================================================== --- call.c (revision 266503) +++ call.c (working copy) @@ -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)) Index: cp-gimplify.c =================================================================== --- cp-gimplify.c (revision 266503) +++ cp-gimplify.c (working copy) @@ -2306,8 +2306,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 Index: cp-objcp-common.c =================================================================== --- cp-objcp-common.c (revision 266503) +++ cp-objcp-common.c (working copy) @@ -248,8 +248,7 @@ 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; @@ -256,8 +255,7 @@ cp_type_dwarf_attribute (const_tree type, int attr 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; Index: cp-tree.h =================================================================== --- cp-tree.h (revision 266503) +++ cp-tree.h (working copy) @@ -4313,8 +4313,7 @@ more_aggr_init_expr_args_p (const aggr_init_expr_a #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. */ @@ -4330,8 +4329,7 @@ more_aggr_init_expr_args_p (const aggr_init_expr_a 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) \ Index: cvt.c =================================================================== --- cvt.c (revision 266503) +++ cvt.c (working copy) @@ -1979,8 +1979,7 @@ perform_qualification_conversions (tree type, tree 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)); } Index: decl.c =================================================================== --- decl.c (revision 266503) +++ decl.c (working copy) @@ -11707,8 +11707,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", @@ -11866,8 +11865,7 @@ grokdeclarator (const cp_declarator *declarator, error ("non-object member %qs cannot be declared %", 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 ("function %qs cannot be declared %", name); storage_class = sc_none; @@ -12245,8 +12243,7 @@ grokdeclarator (const cp_declarator *declarator, error ("invalid use of %<::%>"); return error_mark_node; } - else if (TREE_CODE (type) == FUNCTION_TYPE - || TREE_CODE (type) == METHOD_TYPE) + else if (FUNC_OR_METHOD_TYPE_P (type)) { int publicp = 0; tree function_context; @@ -12550,8 +12547,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; Index: decl2.c =================================================================== --- decl2.c (revision 266503) +++ decl2.c (working copy) @@ -158,8 +158,7 @@ build_memfn_type (tree fntype, tree ctype, cp_cv_q 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); Index: mangle.c =================================================================== --- mangle.c (revision 266503) +++ mangle.c (working copy) @@ -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)); @@ -2071,8 +2070,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) @@ -2103,8 +2101,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 Index: parser.c =================================================================== --- parser.c (revision 266503) +++ parser.c (working copy) @@ -39145,8 +39145,7 @@ cp_parser_omp_declare_reduction (cp_parser *parser || 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); Index: pt.c =================================================================== --- pt.c (revision 266503) +++ pt.c (working copy) @@ -2858,8 +2858,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)) @@ -20422,8 +20421,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; @@ -21379,8 +21377,7 @@ check_cv_quals_for_unify (int strict, tree arg, tr 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; @@ -24960,8 +24957,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; Index: rtti.c =================================================================== --- rtti.c (revision 266503) +++ rtti.c (working copy) @@ -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; Index: semantics.c =================================================================== --- semantics.c (revision 266503) +++ semantics.c (working copy) @@ -1528,8 +1528,7 @@ finish_asm_stmt (int volatile_p, tree string, tree || 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)) @@ -4063,8 +4062,7 @@ finish_offsetof (tree object_ptr, tree expr, locat 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 @@ -5455,8 +5453,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 " Index: tree.c =================================================================== --- tree.c (revision 266503) +++ tree.c (working copy) @@ -1306,8 +1306,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); @@ -4723,8 +4722,7 @@ cp_build_type_attribute_variant (tree type, tree a 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. */ @@ -4739,8 +4737,7 @@ cp_build_type_attribute_variant (tree type, tree a 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; @@ -4757,7 +4754,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)); @@ -5360,8 +5357,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); Index: typeck.c =================================================================== --- typeck.c (revision 266503) +++ typeck.c (working copy) @@ -1261,8 +1261,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; @@ -3990,8 +3989,7 @@ convert_arguments (tree typelist, vec 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); } @@ -5949,8 +5947,7 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue /* 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) @@ -6526,8 +6523,7 @@ unary_complex_lvalue (enum tree_code code, tree ar 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; @@ -7887,8 +7883,7 @@ cp_build_c_cast (tree type, tree expr, tsubst_flag } } - 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); @@ -8235,8 +8230,7 @@ cp_build_modify_expr (location_t loc, tree lhs, en && (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) @@ -9714,7 +9708,7 @@ comp_ptr_ttypes_real (tree to, tree from, int cons /* 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; @@ -9890,8 +9884,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;