From patchwork Wed Jul 19 22:10:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Sayle X-Patchwork-Id: 122848 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp2737212vqt; Wed, 19 Jul 2023 15:11:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlGC7YPiMAM5JpwBMVKHJ6MV/oP1aSpa5CcZOtZR3sJfDTJuGJSjGkwZitbX7UkTLA30Hzx4 X-Received: by 2002:a17:906:749a:b0:973:ff8d:2a46 with SMTP id e26-20020a170906749a00b00973ff8d2a46mr3266516ejl.3.1689804698587; Wed, 19 Jul 2023 15:11:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689804698; cv=none; d=google.com; s=arc-20160816; b=vnMu/6S729rfBE9k4VGJt8Tn5JrePMoh7qeIjOcpz+3nL7s+Yp4Eaoh89vK/mUwxru hTxIhgHdAs56+XFAkgALbQuZtSYgRwyNPbYtFw3Fns3/drYSDRynGM0Qkcs6Wt/Yl4e3 3/6KwQZOGaCjhLpg7dgUMcggfYAhCDDYmkYC9w2qafOKi6hsp9qDUXT3D0nO0dvM46I/ t15FAizLHE1SGO+GGCoELa8jR3JG4akH3YK23tZ9AyX0zXcuhID0/NwUKlGRDDhdKdX3 8O1/vuSKdx8WfLPVrI9jOtNIQ6ntpRj0wnYgogFXUwtKqC4CMl8Jz/RIHfZ67IVcjFIT r6og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-language:thread-index :mime-version:message-id:date:subject:to:from:dkim-signature :dmarc-filter:delivered-to; bh=ifx82EhQvhNDbH1C3AZtvJmAOdNEgPhmrgY4gkj1I6c=; fh=DfnDlPCeFLqrv37HF9+TwvnAeon9XSZzF2Y4zj5YFXs=; b=LDXV++wCVof6qJJLc+Gd55qNjLhlL3C9SjenpbTxaooS9rBBjT9u5SpT9HEEB/F7cL dB3ilg5bgOdWtgsVjzYZpYtq6G2gUdCjuENW9kAoOBuNq9gUQ2Il+l9BGGeWxvhL2KAY S7ZTtvA8XJ4wJKyM9AGEC9b5gpYokYTd1WA4UfLvxcqDrbBVysanvACXs33sV6zTTxMI 32VvgFEzViE6MoU4vMNYqAagca3rFUKQVaP6qQGWPqnkqpMPzKG1OkmY4xR2BSKr4eCk ltPfktOD0mIJYq+XZ35sG5ID79cJ/wLx8lDoQLp3NmrmfqBMklMH8hIxB150fHl9BGDR MQBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nextmovesoftware.com header.s=default header.b=W50rKBuH; 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" Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id jz2-20020a170906bb0200b0098e2a30ec3asi3292771ejb.385.2023.07.19.15.11.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 15:11:38 -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=fail header.i=@nextmovesoftware.com header.s=default header.b=W50rKBuH; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 96C5D3856969 for ; Wed, 19 Jul 2023 22:11:27 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from server.nextmovesoftware.com (server.nextmovesoftware.com [162.254.253.69]) by sourceware.org (Postfix) with ESMTPS id AE0AB3858C2B for ; Wed, 19 Jul 2023 22:10:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AE0AB3858C2B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=nextmovesoftware.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nextmovesoftware.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nextmovesoftware.com; s=default; h=Content-Type:MIME-Version:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=ifx82EhQvhNDbH1C3AZtvJmAOdNEgPhmrgY4gkj1I6c=; b=W50rKBuHZ161IbmnWfueklKFn7 pOQgmkH5MZ9ioPsxJOOswLY68obpdNNavq1zZWeiGmWFLKB3IRCSd87pHPZVkaj23gkTZYbAR6z/b kBZIStscCdEth0OETFOli0hHEi3U6YnTPVSTZXJRZnYIezBTBwD4eIN/7HSuJ2TYo1koeBETzZRKl zO1ONvaQV3u67LW4wssjbIyxyiE86ZjsIWX6CDyYwLAxgrCsX+/7dB+C/aiu/rhsB2HPyJqnEYBY2 H91ynINTKv4g7VeAMxam/Jw1LGIz6zy9h9LjmtTO7WpruWjubJz4C3Uz7LfAjNSdsi4V9of+9uAQ1 sm1u3mTg==; Received: from host86-161-68-50.range86-161.btcentralplus.com ([86.161.68.50]:60696 helo=Dell) by server.nextmovesoftware.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qMFNq-0001gc-1w for gcc-patches@gcc.gnu.org; Wed, 19 Jul 2023 18:10:58 -0400 From: "Roger Sayle" To: Subject: [PATCH] PR c/110699: Defend against error_mark_node in gimplify.cc. Date: Wed, 19 Jul 2023 23:10:57 +0100 Message-ID: <003e01d9ba8d$e5cd4390$b167cab0$@nextmovesoftware.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: Adm6jbCAXGjgnyOPS3GfEUKX9SKeTw== Content-Language: en-gb X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server.nextmovesoftware.com X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - nextmovesoftware.com X-Get-Message-Sender-Via: server.nextmovesoftware.com: authenticated_id: roger@nextmovesoftware.com X-Authenticated-Sender: server.nextmovesoftware.com: roger@nextmovesoftware.com X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, 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: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771888651161229699 X-GMAIL-MSGID: 1771888651161229699 This patch resolves PR c/110699, an ICE-after-error regression, by adding a check that the array type isn't error_mark_node in gimplify_compound_lval. This patch has been tested on x86_64-pc-linux-gnu with make bootstrap and make -k check, both with and without --target_board=unix{-m32} with no new failures. Ok for mainline? 2023-07-19 Roger Sayle gcc/ChangeLog PR c/110699 * gimplify.cc (gimplify_compound_lval): For ARRAY_REF and ARRAY_RANGE_REF return GS_ERROR if the array's type is error_mark_node. gcc/testsuite/ChangeLog PR c/110699 * gcc.dg/pr110699.c: New test case. Cheers, Roger diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc index 36e5df0..4f40b24 100644 --- a/gcc/gimplify.cc +++ b/gcc/gimplify.cc @@ -3211,6 +3211,9 @@ gimplify_compound_lval (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, if (TREE_CODE (t) == ARRAY_REF || TREE_CODE (t) == ARRAY_RANGE_REF) { + if (TREE_TYPE (TREE_OPERAND (t, 0)) == error_mark_node) + return GS_ERROR; + /* Deal with the low bound and element type size and put them into the ARRAY_REF. If these values are set, they have already been gimplified. */ diff --git a/gcc/testsuite/gcc.dg/pr110699.c b/gcc/testsuite/gcc.dg/pr110699.c new file mode 100644 index 0000000..be77613 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr110699.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef __attribute__((__vector_size__(64))) int T; + +void f(void) { + extern char a[64], b[64]; /* { dg-message "previous" "note" } */ + void *p = a; + T q = *(T *)&b[0]; +} + +void g() { + extern char b; /* { dg-error "conflicting types" } */ +}