From patchwork Sat May 13 23:23:16 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: 93631 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp6016988vqo; Sat, 13 May 2023 16:31:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4d2MLZyeUYUlupBZrCCy7kQ5tpJF5eYMPdDc+0HeFgZ6oH3V7FanTe8HguzHMZtk+v88fu X-Received: by 2002:a17:907:7dab:b0:967:a127:7e79 with SMTP id oz43-20020a1709077dab00b00967a1277e79mr19441691ejc.28.1684020684906; Sat, 13 May 2023 16:31:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684020684; cv=none; d=google.com; s=arc-20160816; b=qly0rXUXrscwFJhdUDBFc8ydw/5Rn2G0no7MHCN1kZixbGS+UJO86yzimbInKCjKfn CuUAPb+k1k0L6h+7/P8eyocz/aBqLNwCeLemzHwBbCiEdPY36rHYtCY/e5D0O702yMCW 3LnJXetpLNGnG89qRR9z9INhZ3wzD5eB0ZbCCG/p6sSiiREXdB9+DgUajfyRMsi8DzIO EMi1qTzb2E7UWkEZwFf3KbVlBUNGNnyuK4IO7YHNocMIx1xlZcwzP+qdaS5H+PUZYc5k MTVafxDzxujSB5iUFT4ZoYhAnWXE6EOAjJbpqxlTEJzyO143TCF6LGO7EwoejMFfYnAE Xp7w== 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=UwdphHobJdHdr7kpfathxNdrPsZPCvK03KU6b/A3WQE=; b=cqDD8Haz7RdFCJ84X9C/QaK+MUho3NJts149w0jJqRNIZDF+CQlwFxhGJkD86L0vTc iPI6OIMqjKZHXI+39qqwZ8TIXud0mg3ztDE60isAn5oTY1UzVhGJ0cAH45eYR8tVbBZH 8eswEYPWI5zh40H6dmZBnUFQWIffElkg41DzUMny0x53Z7IsQrlbQlsE8jROZtQsPEA3 uoNWEMEsXML+i3M9lc3LrIZ1QOT6fjwHlUwIgssfDn5TSnUceCvcbwHHlHMQldb+r2Yx kdOp8BGmW70Y5crMLdCyUFiw4brfqk7nApmtwuO0EV2ZyQGcA8UiAEVHO22bWykbIY2c pw6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="Xq+uoRa/"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id bt1-20020a0564020a4100b0050bcc62699csi9261352edb.298.2023.05.13.16.31.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 May 2023 16:31:24 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="Xq+uoRa/"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 4F02B3857345 for ; Sat, 13 May 2023 23:27:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4F02B3857345 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684020474; bh=UwdphHobJdHdr7kpfathxNdrPsZPCvK03KU6b/A3WQE=; 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=Xq+uoRa/Rvtd+KHwJzvVoxfRtMegoyWPg04747qhvXOCervEtljO2gHONIWaCUdSU 3g2AAJ0+0i1lqN0JzqaGiWy5JwTfXfJ4YVU18NOq2pIqkv4JHDZ4elBNz+ARRRrewr 5jHnW80VtUZWXKsk2INuW3LczNhprjkQop1KojO0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id 466A2385841C; Sat, 13 May 2023 23:23:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 466A2385841C Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-965c3f9af2aso1728227666b.0; Sat, 13 May 2023 16:23:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684020232; x=1686612232; 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=UwdphHobJdHdr7kpfathxNdrPsZPCvK03KU6b/A3WQE=; b=IRfNdYaGxUaqJDtJxlmvKYFI5XUNtdw5jjyheIqDhgSxaQqY89+7L/NE6E9lBhEmuL a1ViE3WAk2xGhWUMzSCbgTZpZDzjGfI2JciHQ9XJveq1VcX1COBrZdUYiv+v3cQ6morz T4TCnCmb6foX0cmU1VHWYhIeIkZAr+CUvjPmFm9iCluWDcs75caSDZG+Q9if3Bt1Shlm ofKze37jUgEYAbdzzcMfETXBhV8oIs0sJgkIgd1+XTX2KFh3pmVt7S8uJ22e5t6dji9C nZ1uTmUKAFEKqI3b8vkMYQQt1HzyGBSHEmw9o46TuxGim7ex3GoxRFIkN3o86vtR2vEQ 2RuA== X-Gm-Message-State: AC+VfDwtzw/nMM12vPS5nQHp2pV5BFbHkqDf0eyzv73YAnlx/DD6wVS8 eBWm4xDE1Z6hocsMoSScJ3JTw69Morw= X-Received: by 2002:a17:907:7fa4:b0:96a:8ef4:e1bd with SMTP id qk36-20020a1709077fa400b0096a8ef4e1bdmr8446047ejc.18.1684020232035; Sat, 13 May 2023 16:23:52 -0700 (PDT) Received: from nbbrfq ([2001:871:227:ce8b:afc3:c345:e1dd:564e]) by smtp.gmail.com with ESMTPSA id hy27-20020a1709068a7b00b0094f1fe1696bsm7260438ejc.216.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-001Amn-0R; Sun, 14 May 2023 01:23:48 +0200 To: gcc-patches@gcc.gnu.org Cc: Bernhard Reutner-Fischer Subject: [PATCH 09/14] rust: use _P() defines from tree.h Date: Sun, 14 May 2023 01:23:16 +0200 Message-Id: <20230513232321.279733-10-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.3 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?1765823673865342886?= X-GMAIL-MSGID: =?utf-8?q?1765823673865342886?= From: Bernhard Reutner-Fischer gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::type_cast_expression): Use _P() defines from tree.h * backend/rust-tree.cc (build_cplus_array_type): Ditto. * backend/rust-tree.h (ARITHMETIC_TYPE_P): Ditto. (gnu_vector_type_p): Ditto. * checks/lints/rust-lint-unused-var.cc (check_decl): Ditto. * rust-gcc.cc (Gcc_backend::fill_in_array): Ditto. (Gcc_backend::named_type): Ditto. (Gcc_backend::convert_expression): Ditto. (Gcc_backend::init_statement): Ditto. --- gcc/rust/backend/rust-compile-expr.cc | 2 +- gcc/rust/backend/rust-tree.cc | 2 +- gcc/rust/backend/rust-tree.h | 4 ++-- gcc/rust/checks/lints/rust-lint-unused-var.cc | 2 +- gcc/rust/rust-gcc.cc | 8 ++++---- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index d7945dbf26b..3dc34828e32 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -2267,7 +2267,7 @@ CompileExpr::type_cast_expression (tree type_to_cast_to, tree expr_tree, // FIXME check for TREE_OVERFLOW? return cast; } - else if (TREE_CODE (type_to_cast_to) == REAL_TYPE) + else if (SCALAR_FLOAT_TYPE_P (type_to_cast_to)) { tree cast = convert_to_real (type_to_cast_to, expr_tree); // FIXME diff --git a/gcc/rust/backend/rust-tree.cc b/gcc/rust/backend/rust-tree.cc index 8243d4cf5c6..7e11e6584ae 100644 --- a/gcc/rust/backend/rust-tree.cc +++ b/gcc/rust/backend/rust-tree.cc @@ -2404,7 +2404,7 @@ build_cplus_array_type (tree elt_type, tree index_type, int dependent) } /* Avoid spurious warnings with VLAs (c++/54583). */ - if (TYPE_SIZE (t) && EXPR_P (TYPE_SIZE (t))) + if (CAN_HAVE_LOCATION_P (TYPE_SIZE (t))) suppress_warning (TYPE_SIZE (t), OPT_Wunused); /* Push these needs up to the ARRAY_TYPE so that initialization takes diff --git a/gcc/rust/backend/rust-tree.h b/gcc/rust/backend/rust-tree.h index 284fd873c1c..6d243b7f86e 100644 --- a/gcc/rust/backend/rust-tree.h +++ b/gcc/rust/backend/rust-tree.h @@ -54,7 +54,7 @@ Keep these checks in ascending code order. */ #define ARITHMETIC_TYPE_P(TYPE) \ - (RS_INTEGRAL_TYPE_P (TYPE) || TREE_CODE (TYPE) == REAL_TYPE \ + (RS_INTEGRAL_TYPE_P (TYPE) || SCALAR_FLOAT_TYPE_P (TYPE) \ || TREE_CODE (TYPE) == COMPLEX_TYPE) /* True iff TYPE is cv decltype(nullptr). */ @@ -3250,7 +3250,7 @@ identifier_p (tree t) 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); } extern vec * diff --git a/gcc/rust/checks/lints/rust-lint-unused-var.cc b/gcc/rust/checks/lints/rust-lint-unused-var.cc index ba5ffb9372b..2cf5cd60f15 100644 --- a/gcc/rust/checks/lints/rust-lint-unused-var.cc +++ b/gcc/rust/checks/lints/rust-lint-unused-var.cc @@ -25,7 +25,7 @@ namespace Analysis { static void check_decl (tree *t) { - rust_assert (TREE_CODE (*t) == VAR_DECL || TREE_CODE (*t) == PARM_DECL + rust_assert (VAR_P (*t) || TREE_CODE (*t) == PARM_DECL || TREE_CODE (*t) == CONST_DECL); tree var_name = DECL_NAME (*t); diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc index cf20b5b98e0..b1995bdb56a 100644 --- a/gcc/rust/rust-gcc.cc +++ b/gcc/rust/rust-gcc.cc @@ -886,7 +886,7 @@ Gcc_backend::fill_in_array (tree fill, tree element_type, tree length_tree) if (element_type == error_mark_node || length_tree == error_mark_node) return error_mark_node; - gcc_assert (TYPE_SIZE (element_type) != NULL_TREE); + gcc_assert (COMPLETE_TYPE_P (element_type)); length_tree = fold_convert (sizetype, length_tree); @@ -923,7 +923,7 @@ Gcc_backend::named_type (const std::string &name, tree type, Location location) // give it whatever Rust name we have at this point. if (TYPE_NAME (type) == NULL_TREE && location.gcc_location () == BUILTINS_LOCATION - && (TREE_CODE (type) == INTEGER_TYPE || TREE_CODE (type) == REAL_TYPE + && (TREE_CODE (type) == INTEGER_TYPE || SCALAR_FLOAT_TYPE_P (type) || TREE_CODE (type) == COMPLEX_TYPE || TREE_CODE (type) == BOOLEAN_TYPE)) { @@ -1173,7 +1173,7 @@ Gcc_backend::convert_expression (tree type_tree, tree expr_tree, } else if (TREE_CODE (type_tree) == INTEGER_TYPE) ret = convert_to_integer (type_tree, expr_tree); - else if (TREE_CODE (type_tree) == REAL_TYPE) + else if (SCALAR_FLOAT_TYPE_P (type_tree)) ret = convert_to_real (type_tree, expr_tree); else if (TREE_CODE (type_tree) == COMPLEX_TYPE) ret = convert_to_complex (type_tree, expr_tree); @@ -1935,7 +1935,7 @@ Gcc_backend::init_statement (tree, Bvariable *var, tree init_tree) tree var_tree = var->get_decl (); if (var_tree == error_mark_node || init_tree == error_mark_node) return error_mark_node; - gcc_assert (TREE_CODE (var_tree) == VAR_DECL); + gcc_assert (VAR_P (var_tree)); // To avoid problems with GNU ld, we don't make zero-sized // externally visible variables. That might lead us to doing an