From patchwork Sat May 13 23:23:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Reutner-Fischer X-Patchwork-Id: 93622 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp6015367vqo; Sat, 13 May 2023 16:25:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4iGGBo+vO/XuMxCHcR/6PxQC7Ll30gEiM53AXAzfG/xsk2BRPjp4mlcrdYZTVRvbziy1lp X-Received: by 2002:a17:907:944d:b0:94e:fa56:a74f with SMTP id dl13-20020a170907944d00b0094efa56a74fmr25506509ejc.14.1684020344550; Sat, 13 May 2023 16:25:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684020344; cv=none; d=google.com; s=arc-20160816; b=eN8VfPfAcDO1mzGOduaD16utLkx4ZoxRrwU/lth0G2ruMDr0/sz3blIhGPZX0YyscI JmsXwWxXdFha3BPng/4gsrWI51DnWgqNlnkJn2Z9t5WZXdwPVX6ouW86aWbIjdmky0Ng V/r3a1WrTuSDFG1qfmAEVVutPj6VtCzkXo0jmiQ5uzdrOs6Sbg9UbgRf8uSH9/g++chW tU3tZ+RKyfTip4AMwah83MczijWR+cbdadD49BTOF4XGJSADKXVsYGbnEOdNhjmg6MjS vAzRYGLIlBMVUPRRNOVPj3OiXQMBfadXAACRHe/pYbVdAkn8CL5AiQbtQTdouJ/Ol3d2 11pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=hCL12ukz3HuuPwM+7MkZRoxA0vehmKR7JGbFbt9PC9A=; b=jnnfm3ZYtfNf8DQpW92bk4sHGVaoDBnrdwAcHEJ1gixuJ7lxPyvMQxYB4ETHH1WRy7 7aMDd8efY15Vrx0zM4A0bV+TAN1gjPTzCmQa1gsss6+DifxhN6rbfCgITp/Vd0AXSfVS 2DDXuwf/0+WSfy35sHA8dvpyGjwaDDwEw7KUtE8J5v65a+p/SkngEINkDsSj2B8yeTsw icJ+qjACAxo1XoDdTmK9iuUL9FN/w/pcRTdxivqRrILran/xv2fAc2z0poNWiWPyYpLY bSPIIWlFVLqH3tIsbzFMiAfet62KWu/uoZudgtp8JYWYgTh6nj8qOfWXh/2FSI4IM+/q mBqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ctKuubhf; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ti3-20020a170907c20300b0094f712dac4esi10045471ejc.937.2023.05.13.16.25.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 May 2023 16:25:44 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ctKuubhf; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 487333851C32 for ; Sat, 13 May 2023 23:24:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 487333851C32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684020292; bh=hCL12ukz3HuuPwM+7MkZRoxA0vehmKR7JGbFbt9PC9A=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=ctKuubhfOWm7W7lqGUfOyH9mrru5CxksQuaO/tqyk0GPz0sWvqU6bmao3f1YCMAjA 4rX8Y8+qNMCpur2eA9AfHShDXkOVJ3Ojd1O2WIyqsHRwIH6zfSElLvzltSg8RIqkAB 6zlDLAq4cbTxC7vvqGnVhLjgGIK4BiuasAYhH0ro= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by sourceware.org (Postfix) with ESMTPS id 0F1023858408; Sat, 13 May 2023 23:23:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0F1023858408 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-96ab81aa68dso342020466b.3; Sat, 13 May 2023 16:23:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684020229; x=1686612229; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hCL12ukz3HuuPwM+7MkZRoxA0vehmKR7JGbFbt9PC9A=; b=Sgigd6Rf5nu7YYDpyyEz2N9IMTNkmzsHcYG12udx0raHoIHihfv+bSo1SE2+v85J23 WpA85baojEJBPyYy8QyGyACuVy89NWyPWdwUrPCS0XT8cS528mNrVNV4NhUT0j7BDrOf pq1Mhg0LTcSgIuiZKxtbTqcd8PPe5kTa9YExfYC9W4pdYUsSx3mnZLtXgvQFytqZJISg BIdG+bRAy85pvEzNZ/s5/d1OVP2KZvYswX7P7unV/2vG5UadCW3SJQtwaKV1aF7TL9fz rvQM50qkgavududBohzjWORPhY0asD4nHKxpJT3iHsW94temBbB9wCMb3xC36i84jerp BEew== X-Gm-Message-State: AC+VfDxnA08uU/9R8A7X6FoMQiUaZZQQoPq74hih3eKDUyJaDX+kgSLJ bU5EYSVMeGX+rf5kfDJgg2ivLFSSM4Y= X-Received: by 2002:a17:907:7da0:b0:96a:ed6e:7d58 with SMTP id oz32-20020a1709077da000b0096aed6e7d58mr2003746ejc.7.1684020229094; Sat, 13 May 2023 16:23:49 -0700 (PDT) Received: from nbbrfq ([2001:871:227:ce8b:afc3:c345:e1dd:564e]) by smtp.gmail.com with ESMTPSA id h25-20020a1709070b1900b0094ef923a6ccsm7317336ejl.219.2023.05.13.16.23.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 May 2023 16:23:48 -0700 (PDT) Received: from b by nbbrfq with local (Exim 4.96) (envelope-from ) id 1pxyaa-001Amr-0U; Sun, 14 May 2023 01:23:48 +0200 To: gcc-patches@gcc.gnu.org Cc: Bernhard Reutner-Fischer Subject: [PATCH 10/14] c: use _P() defines from tree.h Date: Sun, 14 May 2023 01:23:17 +0200 Message-Id: <20230513232321.279733-11-rep.dot.nop@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230513232321.279733-1-rep.dot.nop@gmail.com> References: <20230513232321.279733-1-rep.dot.nop@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Bernhard Reutner-Fischer via Gcc-patches From: Bernhard Reutner-Fischer Reply-To: Bernhard Reutner-Fischer Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765823316943114431?= X-GMAIL-MSGID: =?utf-8?q?1765823316943114431?= From: Bernhard Reutner-Fischer gcc/c-family/ChangeLog: * c-ada-spec.cc (has_static_fields): Use _P() defines from tree.h. (dump_ada_declaration): Ditto. (dump_ada_structure): Ditto. * c-common.cc (unsafe_conversion_p): Ditto. (shorten_compare): Ditto. (pointer_int_sum): Ditto. (c_common_truthvalue_conversion): Ditto. (scalar_to_vector): Ditto. * c-common.h (gnu_vector_type_p): Ditto. * c-omp.cc (c_omp_depend_t_p): Ditto. (c_omp_split_clauses): Ditto. * c-ubsan.cc (ubsan_instrument_division): Ditto. * c-warn.cc (conversion_warning): Ditto. (warnings_for_convert_and_check): Ditto. gcc/c/ChangeLog: * c-convert.cc (c_convert): Ditto. * c-decl.cc (merge_decls): Ditto. * c-parser.cc (c_parser_omp_clause_reduction): Ditto. (c_parser_omp_declare_reduction): Ditto. * c-typeck.cc (build_component_ref): Ditto. (convert_argument): Ditto. (pointer_diff): Ditto. (build_unary_op): Ditto. (build_c_cast): Ditto. (build_modify_expr): Ditto. (store_init_value): Ditto. (constexpr_init_fits_real_type): Ditto. (check_constexpr_init): Ditto. (c_finish_return): Ditto. (handle_omp_array_sections_1): Ditto. (c_finish_omp_clauses): Ditto. * gimple-parser.cc (c_finish_gimple_return): Ditto. libcc1/ChangeLog: * libcc1plugin.cc (plugin_float_type): Ditto. * libcp1plugin.cc (plugin_reactivate_decl): Ditto. (plugin_get_float_type): Ditto. --- gcc/c-family/c-ada-spec.cc | 6 ++--- gcc/c-family/c-common.cc | 32 +++++++++++------------ gcc/c-family/c-common.h | 2 +- gcc/c-family/c-omp.cc | 5 ++-- gcc/c-family/c-ubsan.cc | 2 +- gcc/c-family/c-warn.cc | 6 ++--- gcc/c/c-convert.cc | 4 +-- gcc/c/c-decl.cc | 6 ++--- gcc/c/c-parser.cc | 4 +-- gcc/c/c-typeck.cc | 52 +++++++++++++++++++------------------- gcc/c/gimple-parser.cc | 2 +- libcc1/libcc1plugin.cc | 2 +- libcc1/libcp1plugin.cc | 4 +-- 13 files changed, 63 insertions(+), 64 deletions(-) diff --git a/gcc/c-family/c-ada-spec.cc b/gcc/c-family/c-ada-spec.cc index b50b3877564..050994d8416 100644 --- a/gcc/c-family/c-ada-spec.cc +++ b/gcc/c-family/c-ada-spec.cc @@ -1051,7 +1051,7 @@ has_static_fields (const_tree type) return false; for (tree fld = TYPE_FIELDS (type); fld; fld = TREE_CHAIN (fld)) - if (TREE_CODE (fld) == VAR_DECL && DECL_NAME (fld)) + if (VAR_P (fld) && DECL_NAME (fld)) return true; return false; @@ -3244,7 +3244,7 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) if (need_indent) INDENT (spc); - if ((TREE_CODE (t) == FIELD_DECL || TREE_CODE (t) == VAR_DECL) + if ((TREE_CODE (t) == FIELD_DECL || VAR_P (t)) && DECL_NAME (t)) check_type_name_conflict (buffer, t); @@ -3462,7 +3462,7 @@ dump_ada_structure (pretty_printer *buffer, tree node, tree type, bool nested, /* Print the static fields of the structure, if any. */ for (tree tmp = TYPE_FIELDS (node); tmp; tmp = TREE_CHAIN (tmp)) { - if (TREE_CODE (tmp) == VAR_DECL && DECL_NAME (tmp)) + if (VAR_P (tmp) && DECL_NAME (tmp)) { if (need_semicolon) { diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc index 2b4c82facf7..9c8eed5442a 100644 --- a/gcc/c-family/c-common.cc +++ b/gcc/c-family/c-common.cc @@ -1483,7 +1483,7 @@ unsafe_conversion_p (tree type, tree expr, tree result, bool check_sign) /* Warn for real constant that is not an exact integer converted to integer type. */ - if (TREE_CODE (expr_type) == REAL_TYPE + if (SCALAR_FLOAT_TYPE_P (expr_type) && TREE_CODE (type) == INTEGER_TYPE) { if (!real_isinteger (TREE_REAL_CST_PTR (expr), TYPE_MODE (expr_type))) @@ -1508,7 +1508,7 @@ unsafe_conversion_p (tree type, tree expr, tree result, bool check_sign) else give_warning = UNSAFE_OTHER; } - else if (TREE_CODE (type) == REAL_TYPE) + else if (SCALAR_FLOAT_TYPE_P (type)) { /* Warn for an integer constant that does not fit into real type. */ if (TREE_CODE (expr_type) == INTEGER_TYPE) @@ -1519,7 +1519,7 @@ unsafe_conversion_p (tree type, tree expr, tree result, bool check_sign) } /* Warn for a real constant that does not fit into a smaller real type. */ - else if (TREE_CODE (expr_type) == REAL_TYPE + else if (SCALAR_FLOAT_TYPE_P (expr_type) && TYPE_PRECISION (type) < TYPE_PRECISION (expr_type)) { REAL_VALUE_TYPE a = TREE_REAL_CST (expr); @@ -1579,7 +1579,7 @@ unsafe_conversion_p (tree type, tree expr, tree result, bool check_sign) else { /* Warn for real types converted to integer types. */ - if (TREE_CODE (expr_type) == REAL_TYPE + if (SCALAR_FLOAT_TYPE_P (expr_type) && TREE_CODE (type) == INTEGER_TYPE) give_warning = UNSAFE_REAL; @@ -1651,7 +1651,7 @@ unsafe_conversion_p (tree type, tree expr, tree result, bool check_sign) all the range of values of the integer type cannot be represented by the real type. */ else if (TREE_CODE (expr_type) == INTEGER_TYPE - && TREE_CODE (type) == REAL_TYPE) + && SCALAR_FLOAT_TYPE_P (type)) { /* Don't warn about char y = 0xff; float x = (int) y; */ expr = get_unwidened (expr, 0); @@ -1662,8 +1662,8 @@ unsafe_conversion_p (tree type, tree expr, tree result, bool check_sign) } /* Warn for real types converted to smaller real types. */ - else if (TREE_CODE (expr_type) == REAL_TYPE - && TREE_CODE (type) == REAL_TYPE + else if (SCALAR_FLOAT_TYPE_P (expr_type) + && SCALAR_FLOAT_TYPE_P (type) && TYPE_PRECISION (type) < TYPE_PRECISION (expr_type)) give_warning = UNSAFE_REAL; @@ -1677,13 +1677,13 @@ unsafe_conversion_p (tree type, tree expr, tree result, bool check_sign) tree to_type = TREE_TYPE (type); /* Warn for real types converted to integer types. */ - if (TREE_CODE (from_type) == REAL_TYPE + if (SCALAR_FLOAT_TYPE_P (from_type) && TREE_CODE (to_type) == INTEGER_TYPE) give_warning = UNSAFE_REAL; /* Warn for real types converted to smaller real types. */ - else if (TREE_CODE (from_type) == REAL_TYPE - && TREE_CODE (to_type) == REAL_TYPE + else if (SCALAR_FLOAT_TYPE_P (from_type) + && SCALAR_FLOAT_TYPE_P (to_type) && TYPE_PRECISION (to_type) < TYPE_PRECISION (from_type)) give_warning = UNSAFE_REAL; @@ -1706,7 +1706,7 @@ unsafe_conversion_p (tree type, tree expr, tree result, bool check_sign) give_warning = UNSAFE_SIGN; } else if (TREE_CODE (from_type) == INTEGER_TYPE - && TREE_CODE (to_type) == REAL_TYPE + && SCALAR_FLOAT_TYPE_P (to_type) && !int_safely_convertible_to_real_p (from_type, to_type)) give_warning = UNSAFE_OTHER; } @@ -2951,8 +2951,8 @@ shorten_compare (location_t loc, tree *op0_ptr, tree *op1_ptr, unsignedp1 = TYPE_UNSIGNED (TREE_TYPE (op1)); /* If one of the operands must be floated, we cannot optimize. */ - real1 = TREE_CODE (TREE_TYPE (primop0)) == REAL_TYPE; - real2 = TREE_CODE (TREE_TYPE (primop1)) == REAL_TYPE; + real1 = SCALAR_FLOAT_TYPE_P (TREE_TYPE (primop0)); + real2 = SCALAR_FLOAT_TYPE_P (TREE_TYPE (primop1)); /* If first arg is constant, swap the args (changing operation so value is preserved), for canonicalization. Don't do this if @@ -3283,7 +3283,7 @@ pointer_int_sum (location_t loc, enum tree_code resultcode, /* The result is a pointer of the same type that is being added. */ tree result_type = TREE_TYPE (ptrop); - if (TREE_CODE (TREE_TYPE (result_type)) == VOID_TYPE) + if (VOID_TYPE_P (TREE_TYPE (result_type))) { if (complain && warn_pointer_arith) pedwarn (loc, OPT_Wpointer_arith, @@ -3730,7 +3730,7 @@ c_common_truthvalue_conversion (location_t location, tree expr) goto ret; } - if (TREE_CODE (TREE_TYPE (expr)) == FIXED_POINT_TYPE) + if (FIXED_POINT_TYPE_P (TREE_TYPE (expr))) { tree fixed_zero_node = build_fixed (TREE_TYPE (expr), FCONST0 (TYPE_MODE @@ -8649,7 +8649,7 @@ scalar_to_vector (location_t loc, enum tree_code code, tree op0, tree op1, } else if (!integer_only_op /* Allow integer --> real conversion if safe. */ - && (TREE_CODE (type0) == REAL_TYPE + && (SCALAR_FLOAT_TYPE_P (type0) || TREE_CODE (type0) == INTEGER_TYPE) && SCALAR_FLOAT_TYPE_P (TREE_TYPE (type1))) { diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index f96350b64af..336a09f4a40 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -790,7 +790,7 @@ extern bool override_libcpp_locations; inline bool gnu_vector_type_p (const_tree type) { - return TREE_CODE (type) == VECTOR_TYPE && !TYPE_INDIVISIBLE_P (type); + return VECTOR_TYPE_P (type) && !TYPE_INDIVISIBLE_P (type); } struct visibility_flags diff --git a/gcc/c-family/c-omp.cc b/gcc/c-family/c-omp.cc index f72ca4c6acd..4faddb00bbc 100644 --- a/gcc/c-family/c-omp.cc +++ b/gcc/c-family/c-omp.cc @@ -674,8 +674,7 @@ c_omp_depend_t_p (tree type) && ((TREE_CODE (TYPE_NAME (type)) == TYPE_DECL ? DECL_NAME (TYPE_NAME (type)) : TYPE_NAME (type)) == get_identifier ("omp_depend_t")) - && (!TYPE_CONTEXT (type) - || TREE_CODE (TYPE_CONTEXT (type)) == TRANSLATION_UNIT_DECL) + && TYPE_FILE_SCOPE_P (type) && COMPLETE_TYPE_P (type) && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST && !compare_tree_int (TYPE_SIZE (type), @@ -2672,7 +2671,7 @@ c_omp_split_clauses (location_t loc, enum tree_code code, if (TREE_CODE (t) == POINTER_PLUS_EXPR) t = TREE_OPERAND (t, 0); if (TREE_CODE (t) == ADDR_EXPR - || TREE_CODE (t) == INDIRECT_REF) + || INDIRECT_REF_P (t)) t = TREE_OPERAND (t, 0); if (DECL_P (t)) bitmap_clear_bit (&allocate_head, DECL_UID (t)); diff --git a/gcc/c-family/c-ubsan.cc b/gcc/c-family/c-ubsan.cc index cfb7cbf389c..51aa83a378d 100644 --- a/gcc/c-family/c-ubsan.cc +++ b/gcc/c-family/c-ubsan.cc @@ -57,7 +57,7 @@ ubsan_instrument_division (location_t loc, tree op0, tree op1) && sanitize_flags_p (SANITIZE_DIVIDE)) t = fold_build2 (EQ_EXPR, boolean_type_node, op1, build_int_cst (type, 0)); - else if (TREE_CODE (type) == REAL_TYPE + else if (SCALAR_FLOAT_TYPE_P (type) && sanitize_flags_p (SANITIZE_FLOAT_DIVIDE)) { t = fold_build2 (EQ_EXPR, boolean_type_node, diff --git a/gcc/c-family/c-warn.cc b/gcc/c-family/c-warn.cc index 9ac43a1af6e..d4d62c48b20 100644 --- a/gcc/c-family/c-warn.cc +++ b/gcc/c-family/c-warn.cc @@ -1227,7 +1227,7 @@ conversion_warning (location_t loc, tree type, tree expr, tree result) { bool cstresult = (result - && TREE_CODE_CLASS (TREE_CODE (result)) == tcc_constant); + && CONSTANT_CLASS_P (result)); if (TYPE_UNSIGNED (type)) { if (cstresult) @@ -1255,7 +1255,7 @@ conversion_warning (location_t loc, tree type, tree expr, tree result) expr_type, type, expr); } } - else if (TREE_CODE_CLASS (TREE_CODE (result)) == tcc_constant) + else if (CONSTANT_CLASS_P (result)) warning_at (loc, warnopt, "conversion from %qT to %qT changes value from %qE to %qE", expr_type, type, expr, result); @@ -1404,7 +1404,7 @@ warnings_for_convert_and_check (location_t loc, tree type, tree expr, while (TREE_CODE (result) == COMPOUND_EXPR) result = TREE_OPERAND (result, 1); - bool cst = TREE_CODE_CLASS (TREE_CODE (result)) == tcc_constant; + bool cst = CONSTANT_CLASS_P (result); tree exprtype = TREE_TYPE (expr); tree result_diag; /* We're interested in the actual numerical value here, not its ASCII diff --git a/gcc/c/c-convert.cc b/gcc/c/c-convert.cc index 0f35dc4fe9a..5754d00b30a 100644 --- a/gcc/c/c-convert.cc +++ b/gcc/c/c-convert.cc @@ -99,7 +99,7 @@ c_convert (tree type, tree expr, bool init_const) return fold_convert_loc (loc, type, expr); if (TREE_CODE (TREE_TYPE (expr)) == ERROR_MARK) return error_mark_node; - if (TREE_CODE (TREE_TYPE (expr)) == VOID_TYPE) + if (VOID_TYPE_P (TREE_TYPE (expr))) { error ("void value not ignored as it ought to be"); return error_mark_node; @@ -119,7 +119,7 @@ c_convert (tree type, tree expr, bool init_const) case INTEGER_TYPE: if (sanitize_flags_p (SANITIZE_FLOAT_CAST) && current_function_decl != NULL_TREE - && TREE_CODE (TREE_TYPE (expr)) == REAL_TYPE + && SCALAR_FLOAT_TYPE_P (TREE_TYPE (expr)) && COMPLETE_TYPE_P (type)) { expr = save_expr (expr); diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index 1b53f2d0785..e378d461127 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -2746,11 +2746,11 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype) system header. Otherwise, keep source location of definition rather than declaration and of prototype rather than non-prototype unless that prototype is built-in. */ - if (CODE_CONTAINS_STRUCT (TREE_CODE (olddecl), TS_DECL_WITH_VIS) + if (HAS_DECL_ASSEMBLER_NAME_P (olddecl) && DECL_IN_SYSTEM_HEADER (olddecl) && !DECL_IN_SYSTEM_HEADER (newdecl) ) DECL_SOURCE_LOCATION (newdecl) = DECL_SOURCE_LOCATION (olddecl); - else if (CODE_CONTAINS_STRUCT (TREE_CODE (olddecl), TS_DECL_WITH_VIS) + else if (HAS_DECL_ASSEMBLER_NAME_P (olddecl) && DECL_IN_SYSTEM_HEADER (newdecl) && !DECL_IN_SYSTEM_HEADER (olddecl)) DECL_SOURCE_LOCATION (olddecl) = DECL_SOURCE_LOCATION (newdecl); @@ -2777,7 +2777,7 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype) if (VAR_P (olddecl) && C_DECL_THREADPRIVATE_P (olddecl)) C_DECL_THREADPRIVATE_P (newdecl) = 1; - if (CODE_CONTAINS_STRUCT (TREE_CODE (olddecl), TS_DECL_WITH_VIS)) + if (HAS_DECL_ASSEMBLER_NAME_P (olddecl)) { /* Copy the assembler name. Currently, it can only be defined in the prototype. */ diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index c9f06930e3a..11ac8653d5b 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -15730,7 +15730,7 @@ c_parser_omp_clause_reduction (c_parser *parser, enum omp_clause_code kind, OMP_CLAUSE_REDUCTION_INSCAN (c) = 1; if (code == ERROR_MARK || !(INTEGRAL_TYPE_P (type) - || TREE_CODE (type) == REAL_TYPE + || SCALAR_FLOAT_TYPE_P (type) || TREE_CODE (type) == COMPLEX_TYPE)) OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) = c_omp_reduction_lookup (reduc_id, @@ -23293,7 +23293,7 @@ c_parser_omp_declare_reduction (c_parser *parser, enum pragma_context context) if (type == error_mark_node) ; else if ((INTEGRAL_TYPE_P (type) - || TREE_CODE (type) == REAL_TYPE + || SCALAR_FLOAT_TYPE_P (type) || TREE_CODE (type) == COMPLEX_TYPE) && orig_reduc_id == NULL_TREE) error_at (loc, "predeclared arithmetic type in " diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index f619e2a67e7..191a90ff651 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -2662,7 +2662,7 @@ build_component_ref (location_t loc, tree datum, tree component, /* Special-case the error message for "ptr.field" for the case where the user has confused "." vs "->". */ rich_location richloc (line_table, loc); - if (TREE_CODE (datum) == INDIRECT_REF && arrow_loc != UNKNOWN_LOCATION) + if (INDIRECT_REF_P (datum) && arrow_loc != UNKNOWN_LOCATION) { richloc.add_fixit_insert_before (arrow_loc, "(*"); richloc.add_fixit_insert_after (arrow_loc, ")"); @@ -3414,7 +3414,7 @@ convert_argument (location_t ploc, tree function, tree fundecl, unsigned int formal_prec = TYPE_PRECISION (type); if (INTEGRAL_TYPE_P (type) - && TREE_CODE (valtype) == REAL_TYPE) + && SCALAR_FLOAT_TYPE_P (valtype)) warning_at (ploc, OPT_Wtraditional_conversion, "passing argument %d of %qE as integer rather " "than floating due to prototype", @@ -3426,12 +3426,12 @@ convert_argument (location_t ploc, tree function, tree fundecl, "than complex due to prototype", argnum, rname); else if (TREE_CODE (type) == COMPLEX_TYPE - && TREE_CODE (valtype) == REAL_TYPE) + && SCALAR_FLOAT_TYPE_P (valtype)) warning_at (ploc, OPT_Wtraditional_conversion, "passing argument %d of %qE as complex rather " "than floating due to prototype", argnum, rname); - else if (TREE_CODE (type) == REAL_TYPE + else if (SCALAR_FLOAT_TYPE_P (type) && INTEGRAL_TYPE_P (valtype)) warning_at (ploc, OPT_Wtraditional_conversion, "passing argument %d of %qE as floating rather " @@ -3443,7 +3443,7 @@ convert_argument (location_t ploc, tree function, tree fundecl, "passing argument %d of %qE as complex rather " "than integer due to prototype", argnum, rname); - else if (TREE_CODE (type) == REAL_TYPE + else if (SCALAR_FLOAT_TYPE_P (type) && TREE_CODE (valtype) == COMPLEX_TYPE) warning_at (ploc, OPT_Wtraditional_conversion, "passing argument %d of %qE as floating rather " @@ -3452,8 +3452,8 @@ convert_argument (location_t ploc, tree function, tree fundecl, /* ??? At some point, messages should be written about conversions between complex types, but that's too messy to do now. */ - else if (TREE_CODE (type) == REAL_TYPE - && TREE_CODE (valtype) == REAL_TYPE) + else if (SCALAR_FLOAT_TYPE_P (type) + && SCALAR_FLOAT_TYPE_P (valtype)) { /* Warn if any argument is passed as `float', since without a prototype it would be `double'. */ @@ -4131,7 +4131,7 @@ pointer_diff (location_t loc, tree op0, tree op1, tree *instrument_expr) else inttype = restype; - if (TREE_CODE (target_type) == VOID_TYPE) + if (VOID_TYPE_P (target_type)) pedwarn (loc, OPT_Wpointer_arith, "pointer of type % used in subtraction"); if (TREE_CODE (target_type) == FUNCTION_TYPE) @@ -4828,7 +4828,7 @@ build_unary_op (location_t location, enum tree_code code, tree xarg, TREE_TYPE (argtype)); } else if (TREE_CODE (TREE_TYPE (argtype)) == FUNCTION_TYPE - || TREE_CODE (TREE_TYPE (argtype)) == VOID_TYPE) + || VOID_TYPE_P (TREE_TYPE (argtype))) { if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR) pedwarn (location, OPT_Wpointer_arith, @@ -6251,7 +6251,7 @@ build_c_cast (location_t loc, tree type, tree expr) /* Ignore any integer overflow caused by the cast. */ if (TREE_CODE (value) == INTEGER_CST && !FLOAT_TYPE_P (otype)) { - if (CONSTANT_CLASS_P (ovalue) && TREE_OVERFLOW (ovalue)) + if (TREE_OVERFLOW_P (ovalue)) { if (!TREE_OVERFLOW (value)) { @@ -6477,7 +6477,7 @@ build_modify_expr (location_t location, tree lhs, tree lhs_origtype, if (TREE_CODE (lhs) == COMPONENT_REF && (TREE_CODE (lhstype) == INTEGER_TYPE || TREE_CODE (lhstype) == BOOLEAN_TYPE - || TREE_CODE (lhstype) == REAL_TYPE + || SCALAR_FLOAT_TYPE_P (lhstype) || TREE_CODE (lhstype) == ENUMERAL_TYPE)) lhstype = TREE_TYPE (get_unwidened (lhs, 0)); @@ -7938,7 +7938,7 @@ store_init_value (location_t init_loc, tree decl, tree init, tree origtype) /* Not fully determined before folding. */ arith_const_expr = true; } - bool constexpr_p = (TREE_CODE (decl) == VAR_DECL + bool constexpr_p = (VAR_P (decl) && C_DECL_DECLARED_CONSTEXPR (decl)); value = digest_init (init_loc, type, init, origtype, npc, int_const_expr, arith_const_expr, true, @@ -8119,7 +8119,7 @@ print_spelling (char *buffer) static bool constexpr_init_fits_real_type (tree type, tree init) { - gcc_assert (TREE_CODE (type) == REAL_TYPE); + gcc_assert (SCALAR_FLOAT_TYPE_P (type)); gcc_assert (TREE_CODE (init) == INTEGER_CST || TREE_CODE (init) == REAL_CST); if (TREE_CODE (init) == REAL_CST && TYPE_MODE (TREE_TYPE (init)) == TYPE_MODE (type)) @@ -8226,14 +8226,14 @@ check_constexpr_init (location_t loc, tree type, tree init, compatible (not just the same mode); all quiet NaN and infinity initializations are considered to preserve the value. */ if (TREE_CODE (TREE_TYPE (init)) == COMPLEX_TYPE - && TREE_CODE (type) == REAL_TYPE) + && SCALAR_FLOAT_TYPE_P (type)) { error_at (loc, "% initializer for a real type is of " "complex type"); return; } - if (TREE_CODE (type) == REAL_TYPE - && TREE_CODE (TREE_TYPE (init)) == REAL_TYPE + if (SCALAR_FLOAT_TYPE_P (type) + && SCALAR_FLOAT_TYPE_P (TREE_TYPE (init)) && DECIMAL_FLOAT_TYPE_P (TREE_TYPE (init)) && !DECIMAL_FLOAT_TYPE_P (type)) { @@ -11313,7 +11313,7 @@ c_finish_return (location_t loc, tree retval, tree origtype) "declared here"); } } - else if (valtype == NULL_TREE || TREE_CODE (valtype) == VOID_TYPE) + else if (valtype == NULL_TREE || VOID_TYPE_P (valtype)) { current_function_returns_null = 1; bool warned_here; @@ -11345,7 +11345,7 @@ c_finish_return (location_t loc, tree retval, tree origtype) save = in_late_binary_op; if (C_BOOLEAN_TYPE_P (TREE_TYPE (res)) || TREE_CODE (TREE_TYPE (res)) == COMPLEX_TYPE - || (TREE_CODE (TREE_TYPE (t)) == REAL_TYPE + || (SCALAR_FLOAT_TYPE_P (TREE_TYPE (t)) && (TREE_CODE (TREE_TYPE (res)) == INTEGER_TYPE || TREE_CODE (TREE_TYPE (res)) == ENUMERAL_TYPE) && sanitize_flags_p (SANITIZE_FLOAT_CAST))) @@ -13668,7 +13668,7 @@ handle_omp_array_sections_1 (tree c, tree t, vec &types, t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]); return error_mark_node; } - while (TREE_CODE (t) == INDIRECT_REF) + while (INDIRECT_REF_P (t)) { t = TREE_OPERAND (t, 0); STRIP_NOPS (t); @@ -13702,7 +13702,7 @@ handle_omp_array_sections_1 (tree c, tree t, vec &types, } t = TREE_OPERAND (t, 0); while (TREE_CODE (t) == MEM_REF - || TREE_CODE (t) == INDIRECT_REF + || INDIRECT_REF_P (t) || TREE_CODE (t) == ARRAY_REF) { t = TREE_OPERAND (t, 0); @@ -15402,7 +15402,7 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) { t = TREE_OPERAND (t, 0); if (TREE_CODE (t) == MEM_REF - || TREE_CODE (t) == INDIRECT_REF) + || INDIRECT_REF_P (t)) { t = TREE_OPERAND (t, 0); STRIP_NOPS (t); @@ -15479,7 +15479,7 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) bias) to zero here, so it is not set erroneously to the pointer size later on in gimplify.cc. */ OMP_CLAUSE_SIZE (c) = size_zero_node; - while (TREE_CODE (t) == INDIRECT_REF + while (INDIRECT_REF_P (t) || TREE_CODE (t) == ARRAY_REF) { t = TREE_OPERAND (t, 0); @@ -15495,7 +15495,7 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) indir_component_ref_p = false; if (TREE_CODE (t) == COMPONENT_REF && (TREE_CODE (TREE_OPERAND (t, 0)) == MEM_REF - || TREE_CODE (TREE_OPERAND (t, 0)) == INDIRECT_REF + || INDIRECT_REF_P (TREE_OPERAND (t, 0)) || TREE_CODE (TREE_OPERAND (t, 0)) == ARRAY_REF)) { t = TREE_OPERAND (TREE_OPERAND (t, 0), 0); @@ -15550,7 +15550,7 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) t = TREE_OPERAND (t, 0); } while (TREE_CODE (t) == MEM_REF - || TREE_CODE (t) == INDIRECT_REF + || INDIRECT_REF_P (t) || TREE_CODE (t) == ARRAY_REF) { t = TREE_OPERAND (t, 0); @@ -16094,7 +16094,7 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) if (TREE_CODE (t) == POINTER_PLUS_EXPR) t = TREE_OPERAND (t, 0); if (TREE_CODE (t) == ADDR_EXPR - || TREE_CODE (t) == INDIRECT_REF) + || INDIRECT_REF_P (t)) t = TREE_OPERAND (t, 0); if (DECL_P (t)) bitmap_clear_bit (&aligned_head, DECL_UID (t)); @@ -16131,7 +16131,7 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) { tree t = OMP_CLAUSE_DECL (c); while (handled_component_p (t) - || TREE_CODE (t) == INDIRECT_REF + || INDIRECT_REF_P (t) || TREE_CODE (t) == ADDR_EXPR || TREE_CODE (t) == MEM_REF || TREE_CODE (t) == NON_LVALUE_EXPR) diff --git a/gcc/c/gimple-parser.cc b/gcc/c/gimple-parser.cc index 5423a790cc0..cc3a8899d97 100644 --- a/gcc/c/gimple-parser.cc +++ b/gcc/c/gimple-parser.cc @@ -2472,7 +2472,7 @@ c_finish_gimple_return (location_t loc, tree retval) if (! retval) current_function_returns_null = 1; - else if (valtype == 0 || TREE_CODE (valtype) == VOID_TYPE) + else if (valtype == 0 || VOID_TYPE_P (valtype)) { current_function_returns_null = 1; if (TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE) diff --git a/libcc1/libcc1plugin.cc b/libcc1/libcc1plugin.cc index 7e0fecae145..283eaf20685 100644 --- a/libcc1/libcc1plugin.cc +++ b/libcc1/libcc1plugin.cc @@ -632,7 +632,7 @@ plugin_float_type (cc1_plugin::connection *self, if (!result) return convert_out (error_mark_node); - gcc_assert (TREE_CODE (result) == REAL_TYPE); + gcc_assert (SCALAR_FLOAT_TYPE_P (result)); gcc_assert (BITS_PER_UNIT * size_in_bytes == TYPE_PRECISION (result)); return convert_out (result); diff --git a/libcc1/libcp1plugin.cc b/libcc1/libcp1plugin.cc index 8d394c0cfdb..3c8e9e8b436 100644 --- a/libcc1/libcp1plugin.cc +++ b/libcc1/libcp1plugin.cc @@ -713,7 +713,7 @@ plugin_reactivate_decl (cc1_plugin::connection *, { tree decl = convert_in (decl_in); tree scope = convert_in (scope_in); - gcc_assert (TREE_CODE (decl) == VAR_DECL + gcc_assert (VAR_P (decl) || TREE_CODE (decl) == FUNCTION_DECL || TREE_CODE (decl) == TYPE_DECL); cp_binding_level *b; @@ -3296,7 +3296,7 @@ plugin_get_float_type (cc1_plugin::connection *, if (!result) return convert_out (error_mark_node); - gcc_assert (TREE_CODE (result) == REAL_TYPE); + gcc_assert (SCALAR_FLOAT_TYPE_P (result)); gcc_assert (BITS_PER_UNIT * size_in_bytes == TYPE_PRECISION (result)); return convert_out (result);