From patchwork Fri Dec 2 14:12:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 28925 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp880432wrr; Fri, 2 Dec 2022 06:13:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf6ISi7cyLTYXRVlB1jD8XDZZqK46Vbhnj+5xqZXfdw6I4pn+3gSfFNu6YmfhzKJvpUqPeeF X-Received: by 2002:a17:906:a156:b0:78d:9b8b:93cc with SMTP id bu22-20020a170906a15600b0078d9b8b93ccmr7090565ejb.529.1669990394831; Fri, 02 Dec 2022 06:13:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669990394; cv=none; d=google.com; s=arc-20160816; b=cpj1Owan2xNvTyS/56aiQGojN6Q9uykoyZQNM0dV0ImCXKj/33gpLgmF05gqImS0Nb LvPavlEd8ykGQp2RIzXMDYo+5WSATs8+jpeBOKxO567vTYG1TQKeNJUHLjbJD0PXiAZC wNtGzuC4Hf5kXbOo7XJgDbvhK1K6qCaCk57m8iZeQbYQjHEVw0OYfpXzG0yZCFuQp8DF ylNgIjDZpku4XvQ5uPPREOzCpT8n8RlBbiS5Z0LFw8n/voipukSi1XurHQ8L+xhMLm2R p4iEbWaEV61yj5ebNphKC+5D65TJnQDUKhRETLQzs/ZRvOS/e6lVNfzp+iL6Cs4LZrFg 3SWQ== 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-language :subject:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=Ta1jGzNboDQyJwuglGDoAGMK+qzxyCk+DLmgDU5R5cw=; b=wOJZds861AkPBNl/i8ZxMBgDKGoloVF+6+cFUJbVJkYcfa/DrmKLXQKe11N7VUPY8s 0jTjYC4x31dAS7MPsaeTtAhTiaOS7B7XRMFLJdeR2jobrbhbYQhoxWOWSWH7gYuyYiwg XGk3BGzgnmmoG8LlL5JZwy08UBAtG4J+zfFIXC5nDwqSQ2to3myQjjqms5i7Rbo1we2H WX9kyK94wG5EG0HzWZwX3UupXgkaNb2vEs3nzXpQhnSHLMDDNmk3M5wkw7t1wAgnbDXo 2uJN3W7rp874rBSHRLBsR8OsUXzecEq+uA7Md0jfgyg8WgoAGSkQ+rzmPzu89tNI8L5X 2qvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Gcco0KvV; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id y12-20020a056402270c00b0046c2a42d72asi2051249edd.404.2022.12.02.06.13.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 06:13:14 -0800 (PST) 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=Gcco0KvV; 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 CDAFD3858407 for ; Fri, 2 Dec 2022 14:13:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CDAFD3858407 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669990393; bh=Ta1jGzNboDQyJwuglGDoAGMK+qzxyCk+DLmgDU5R5cw=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Gcco0KvVjDy3HOmw/kaLchp5/Vorue1gc2xI4Of/1o9ACEe2KEuKgvnifd32aqs69 62Zcj8VWF9OpOpgJzIwYYoxv3/zk1rATmXlI4c9qOMfk/kPb5L8z3eGVgGgwV/7rXq /s+kKdFrDhylWteAJFh+BSJwLMhYTKJhJPUgIpz0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id DA5E73858D28 for ; Fri, 2 Dec 2022 14:12:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DA5E73858D28 Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-474-ICS_SAcnN_iMez4CvqGPPA-1; Fri, 02 Dec 2022 09:12:27 -0500 X-MC-Unique: ICS_SAcnN_iMez4CvqGPPA-1 Received: by mail-io1-f69.google.com with SMTP id e12-20020a056602044c00b006dfbda66242so4655489iov.2 for ; Fri, 02 Dec 2022 06:12:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=subject:from:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cnlGOuG63cMrMIAUqUOTwOjrcRJr1+om/1pfba53SLE=; b=YoCLm1fxARDSrYP1O6Z/x34agLh4iedp+LW62ZkCSc429VlGGlnONZ3FSeU8U+M1xW 7fInwzzhG0ENIJYsZitz9jPVy9p+H718P9Mlv4jPFTR2vjVHduFKrhBxr9LND/H9Gp9r P4x5aXds/n+rOpwf/aVH0wbU6kCRaqT0uykJrLAo26j+eyGXpWC3v2r6E3Nsbxgg+odL de3RQSfTCEwXYn25+06Az1z8KoxYunfREpvWLLRZZ0MMtYK0iVDPyYYar+TNrxBb/uHB rNh9SLbmkMRqTQPPkEGlHuKTop7Mnk4OhQdplCBYoZqQCJxtsYfrehiNgB8UmT+wrSAA Spxw== X-Gm-Message-State: ANoB5pk5hM2ewu4wo5ESxhdf7qOpVrfoEgvqVRByrzmIU7PA0/oPmrbq 0y7kZyGsyemGwdes+IA+ACO28JPCNSWSubS1HkOnaG5Bn4xgeT9bj1jRIEYZNRIK69HbWDdI7bP UwO2XKY+eRPNP8wTiH8cC73BPZLE1D+17RqTlTzGa3IffjJ2bQV7HaELcTJvT8EhdIu/xZQ== X-Received: by 2002:a05:6638:34a1:b0:38a:2138:5d25 with SMTP id t33-20020a05663834a100b0038a21385d25mr1211368jal.273.1669990346209; Fri, 02 Dec 2022 06:12:26 -0800 (PST) X-Received: by 2002:a05:6638:34a1:b0:38a:2138:5d25 with SMTP id t33-20020a05663834a100b0038a21385d25mr1211347jal.273.1669990345715; Fri, 02 Dec 2022 06:12:25 -0800 (PST) Received: from ?IPV6:2607:fea8:a263:f600::d073? ([2607:fea8:a263:f600::d073]) by smtp.gmail.com with ESMTPSA id m36-20020a026a64000000b00389be83f294sm2625421jaf.133.2022.12.02.06.12.24 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 02 Dec 2022 06:12:24 -0800 (PST) Message-ID: Date: Fri, 2 Dec 2022 09:12:23 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 To: gcc-patches Subject: [PATCH] Fix a few incorrect accesses. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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-Content-Filtered-By: Mailman/MimeDel 2.1.29 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: Andrew MacLeod via Gcc-patches From: Andrew MacLeod Reply-To: Andrew MacLeod 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?1751111847920438367?= X-GMAIL-MSGID: =?utf-8?q?1751111847920438367?= This consists of 3 changes which stronger type checking has indicated are non-compliant with the type field. I doubt they are super important because there has not been a trap triggered by them, and they have been in the source base since sometime before 2017.  However, we should probably fix them. I also notice that those are all uses of VOID_TYPE_P, which coincidentally does not check if its a type node being checked: /* Nonzero if this type is the (possibly qualified) void type.  */ #define VOID_TYPE_P(NODE) (TREE_CODE (NODE) == VOID_TYPE) So I guess it wouldn't trap anyway, just silently never trigger. Bootstraps on x86_64-pc-linux-gnu with no regressions.  OK for trunk? Andrew From d1003e853d1813105eef6e441578e5bea9de8d03 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Tue, 29 Nov 2022 13:07:28 -0500 Subject: [PATCH] Fix a few incorrect accesses. This consists of 3 changes which stronger type checking has indicated are incorrect. gcc/ * fold-const.cc (fold_unary_loc): Check TREE_TYPE of node. (tree_invalid_nonnegative_warnv_p): Likewise. gcc/c-family/ * c-attribs.cc (handle_deprecated_attribute): Use type when using TYPE_NAME. --- gcc/c-family/c-attribs.cc | 2 +- gcc/fold-const.cc | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc index 07bca68e9b9..b36dd97802b 100644 --- a/gcc/c-family/c-attribs.cc +++ b/gcc/c-family/c-attribs.cc @@ -4240,7 +4240,7 @@ handle_deprecated_attribute (tree *node, tree name, if (type && TYPE_NAME (type)) { if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE) - what = TYPE_NAME (*node); + what = TYPE_NAME (type); else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL && DECL_NAME (TYPE_NAME (type))) what = DECL_NAME (TYPE_NAME (type)); diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc index 114258fa182..e80be8049e1 100644 --- a/gcc/fold-const.cc +++ b/gcc/fold-const.cc @@ -9369,8 +9369,8 @@ fold_unary_loc (location_t loc, enum tree_code code, tree type, tree op0) && TREE_CODE (tem) == COND_EXPR && TREE_CODE (TREE_OPERAND (tem, 1)) == code && TREE_CODE (TREE_OPERAND (tem, 2)) == code - && ! VOID_TYPE_P (TREE_OPERAND (tem, 1)) - && ! VOID_TYPE_P (TREE_OPERAND (tem, 2)) + && ! VOID_TYPE_P (TREE_TYPE (TREE_OPERAND (tem, 1))) + && ! VOID_TYPE_P (TREE_TYPE (TREE_OPERAND (tem, 2))) && (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (tem, 1), 0)) == TREE_TYPE (TREE_OPERAND (TREE_OPERAND (tem, 2), 0))) && (! (INTEGRAL_TYPE_P (TREE_TYPE (tem)) @@ -15002,7 +15002,7 @@ tree_invalid_nonnegative_warnv_p (tree t, bool *strict_overflow_p, int depth) /* If the initializer is non-void, then it's a normal expression that will be assigned to the slot. */ - if (!VOID_TYPE_P (t)) + if (!VOID_TYPE_P (TREE_TYPE (t))) return RECURSE (t); /* Otherwise, the initializer sets the slot in some way. One common -- 2.38.1