From patchwork Thu Oct 13 20:13:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 2353 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp461940wrs; Thu, 13 Oct 2022 13:15:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7T0j5VEDoa/Q2NV773Ojwc0wn8Q0nmhJfo5Q05GOYHjuW5bO634JKlhQfqxJ+Qm9/zbZXa X-Received: by 2002:a17:907:2710:b0:78d:9be4:492a with SMTP id w16-20020a170907271000b0078d9be4492amr1057155ejk.151.1665692104571; Thu, 13 Oct 2022 13:15:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665692104; cv=none; d=google.com; s=arc-20160816; b=EX92PufaHR/KVFfWHgPv+3Gf/2U99V8plQht6J03pcUx5tTSWQxcmkzvzd2Ke3xb4V 9ALzKTY359EnCQVTp2XIwffUzlYiTK7Obz+L4+tyKbH2bji8jb+GkLAg9NSY0UPdH3AA prX//ftdmk5z1WEoPSTdalBKuP9DRqKDPyDmNRT/yCoP64/uCpSsm701yVYpFcXykU5s U9uVV2lXVICqGpQVah9ItipryqAKDJMRyGVwaetmB6s3Ke/jqBtHxexNBsK9DHyCb0Xn 2E114Os9YLXhEtnCKpNCXbVpevLUV+PwugAyyHwln08g/TDJnaBH5Nfbsou82Y4XBAOY a1lA== 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:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=x0vuePBa72jdlo9kf6P6gW8aV+FWKoXXJ5+ZI2iTRT8=; b=wmWlDmFAoRiijd8EAHd71QggcY+bL+Zw7HbIxvqtC9OeqELpFV1U026j60JZcQwKyH z/cn8DLWT2Met5EvU9yjlMdt1fe2ZR3a53+Bohs0bUIahceJ/yjJqUaltiN4TNLbCicy 7BQir97TaddcVSLrUF2fJF7qw8OQIJYO4yxC9XUcHvRGyNcAH82S+fJKwgnxI2tc2Z21 ksHHfHcQpp1W16dBERPz3e6+DYLbPIuSKbu2a2VLOkPkySjd+srw3dRdzOhs4XzFCQo6 OBXIirLkMnRjgp4mQ+E4xl2ubi1ODVnezSIbV+YC0WBcHCyY5r/81cjBh6Uri83FWPOd bwKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=tsngyE8D; 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 md5-20020a170906ae8500b00783c42d2da2si512014ejb.415.2022.10.13.13.15.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 13:15:04 -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=tsngyE8D; 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 9F6EE385087A for ; Thu, 13 Oct 2022 20:14:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9F6EE385087A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665692071; bh=x0vuePBa72jdlo9kf6P6gW8aV+FWKoXXJ5+ZI2iTRT8=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=tsngyE8Do54ES5ZKxnk6dvjt80hVrjYvvcpVzntFw1nLLnkKuIxOyNStZB8mbzikq QixNDrk+XmuoQNichrpCD/gTUiAwl7gNrTpiE3GkQQcVJfql2RFK0mz7VIaEjB1QC9 rE78+qMq2hkQNj8nuWYYwBJv+79vO46zyH5jnHR4= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id 475A63858C56 for ; Thu, 13 Oct 2022 20:13:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 475A63858C56 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-297-76LnPYe-M6eo3RRiQlA7AA-1; Thu, 13 Oct 2022 16:13:46 -0400 X-MC-Unique: 76LnPYe-M6eo3RRiQlA7AA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9145E88B7A7 for ; Thu, 13 Oct 2022 20:13:40 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.2.17.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC472208DDB6; Thu, 13 Oct 2022 20:13:33 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [committed] analyzer: fix ICE introduced in r13-3168 [PR107210] Date: Thu, 13 Oct 2022 16:13:32 -0400 Message-Id: <20221013201332.1157829-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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-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: David Malcolm via Gcc-patches From: David Malcolm Reply-To: David Malcolm 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?1746604764145325792?= X-GMAIL-MSGID: =?utf-8?q?1746604764145325792?= Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-3285-g99da523359e933. gcc/analyzer/ChangeLog: PR analyzer/107210 * svalue.cc (constant_svalue::maybe_fold_bits_within): Only attempt to extract individual bits when tree_fits_uhwi_p. gcc/testsuite/ChangeLog: PR analyzer/107210 * gfortran.dg/analyzer/pr107210.f90: New test. Signed-off-by: David Malcolm --- gcc/analyzer/svalue.cc | 3 ++- gcc/testsuite/gfortran.dg/analyzer/pr107210.f90 | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/analyzer/pr107210.f90 diff --git a/gcc/analyzer/svalue.cc b/gcc/analyzer/svalue.cc index a0838c0f588..4b00a81b31d 100644 --- a/gcc/analyzer/svalue.cc +++ b/gcc/analyzer/svalue.cc @@ -884,7 +884,8 @@ constant_svalue::maybe_fold_bits_within (tree type, if (bits.m_size_in_bits == 1 && TREE_CODE (m_cst_expr) == INTEGER_CST && type - && INTEGRAL_TYPE_P (type)) + && INTEGRAL_TYPE_P (type) + && tree_fits_uhwi_p (m_cst_expr)) { unsigned HOST_WIDE_INT bit = bits.m_start_bit_offset.to_uhwi (); unsigned HOST_WIDE_INT mask = (1 << bit); diff --git a/gcc/testsuite/gfortran.dg/analyzer/pr107210.f90 b/gcc/testsuite/gfortran.dg/analyzer/pr107210.f90 new file mode 100644 index 00000000000..6132db48817 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/analyzer/pr107210.f90 @@ -0,0 +1,16 @@ +! { dg-additional-options "-O1" } + +subroutine check_int (j) + INTEGER(4) :: i, ia(5), ib(5,4), ip, ipa(:) + target :: ib + POINTER :: ip, ipa + logical :: l(5) + + ipa=>ib(2:3,1) + + l = (/ sizeof(i) == 4, sizeof(ia) == 20, sizeof(ib) == 80, & + sizeof(ip) == 4, sizeof(ipa) == 8 /) + + if (any(.not.l)) STOP 4 + +end subroutine check_int