From patchwork Wed Feb 1 20:24:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 51547 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp493867wrn; Wed, 1 Feb 2023 12:25:45 -0800 (PST) X-Google-Smtp-Source: AK7set+HAc6nAj7KuN/KM7tUB0AFZMxpZZpyazSLuyPfD6bSRKKN5YN8S++g/ZnuzVy1PPPPkv1Z X-Received: by 2002:a05:6402:f91:b0:4a2:4223:25ab with SMTP id eh17-20020a0564020f9100b004a2422325abmr3857439edb.30.1675283145242; Wed, 01 Feb 2023 12:25:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675283145; cv=none; d=google.com; s=arc-20160816; b=QhoNQMgpw30DnHxyqcDMvV2rhr4+/C/a6DsZWu0aEbD2zltD5VKMSuJLWlTQBw39GE W9rYOUeoAmGkMrx1+PvQWqoFBF8zuc+HzyoCoonSTtQBTo0U+QCHf/T/K4QKE4qIhu06 sFZEmdoc/03GCXUPSCx9LgGWfW9+/Qaj5T/nRGiFeoKRWTr2OkOWug2IZDIJeklLaLPd YTb6otW05zfEvh+7m1w8UzSW7TGbeiywxXcUpLf+APzspBQYlQD0fuaDItYRFXVBirL3 T3vgU1k4kMBMWR45rC14Dq7dLy1a+XIKSVRxJma/DnrsU97sQlVIP7GSx4oIvQw9vQGi FrxQ== 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:ui-outboundreport :sensitivity:importance:date:subject:to:message-id:mime-version :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=e9AbIicSHzNVRFzl0x2qBASOp1LGPx89v5vOmbJpH58=; b=C++TMTIiP4+6edCbPq85YYdbLrMBQAcK2CQfnV7eieoppVO8dez/shIX3QvPUnkuz/ FEgLuuZYeHFAxXa/IwGVsrz34LKV4ffObpDJGnt+9dN3aQRMbiMrS7PNJAOZxaSkgw3H Jvi+c8/n53BM82JspXeAEP+/KRxvxrEH87SpIWqJ5D0olh83M5BtcEEovT3CfmhEqEwF BmOE1FJSApdMfdbsEnGJCWqfpn9k2Dme6/7pIIZhky/d9fEaABWN8R8csC76ANPd6Fwv x01uj08ws12+6UUp4rlCl+J7tdfROVa1qCEf/fxRTrf3+mtMSmWgdcX9z5a0bWdF7LzH 2xkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=XjEl0Jll; 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 fe9-20020a056402390900b004a343c1cb51si3456653edb.593.2023.02.01.12.25.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 12:25:45 -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=XjEl0Jll; 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 4852A3858D33 for ; Wed, 1 Feb 2023 20:25:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4852A3858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675283144; bh=e9AbIicSHzNVRFzl0x2qBASOp1LGPx89v5vOmbJpH58=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=XjEl0JlljDSt9bqh4xa81tU+1g99u50tizFc6jGzKtNddHH6TgRxyp9yqOOp81klq BviU8tLR4UTekEmgQEPrGqkKjjitHbC0LKGV6gT30WC15v+k4zI9V72vmAx7n2GeHW 9Giaj2dq29ZlWFWDotl+VA2Dmh4mGI4yLlAt31/M= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by sourceware.org (Postfix) with ESMTPS id 9ED6A3858D33; Wed, 1 Feb 2023 20:25:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9ED6A3858D33 X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [93.207.88.137] ([93.207.88.137]) by web-mail.gmx.net (3c-app-gmx-bs72.server.lan [172.19.170.208]) (via HTTP); Wed, 1 Feb 2023 21:24:59 +0100 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH, committed] Fortran: error recovery on invalid array section [PR108609] Date: Wed, 1 Feb 2023 21:24:59 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:4gCn5RrLXrQqB8GvN0Re9p9Nd6XtDI+kRmILM++R0mTh2vNUOigamK5sSoCbWSxIRq5fR 0HqM+zq/yHhVAASsq3PaN5T8Pq+FGUuQMrlj4v9Wqodhe/OUaCAaBNn4DoNbnn+6wwlUt0lzIQ6c 0Dti85C0YpYCxtJiujy1h7GAF+zhOHFrfIVBUkyey0cbgXJVg+JszuRW8jpMat4frKVOcgZEPrru leXOyLGuQBBqla8Bl3O8vFZ/qGTmmNjDLun4+6qzo3j8Vm5h5JVml3zCAc1Oyx1E7thImEcS2Mfc Ow= UI-OutboundReport: notjunk:1;M01:P0:DaDQP1Jg12E=;ZMjppy6LdaZDhsc0fI5xOS8AkoS ZOOXD9oAtye4gaWK6JYYCHW5zpu1zJebx0SvoqK+9C92CjKdl+NvlgE3ln383cChSAoONLm+3 icWuak0urZlJSZgOSJSOcn38sMd/wu+J/31My4dzASJSN7u8yib8127YoUDXT/K3/HhPbfvKp tD5s6aHFdvywcAWvTE7wCS38AK+jvf0CbThZMWJU7dTXxkycPvttgZshjxP/9q6DJ0PhE3SaP 7FQSZUBvii2TQKbg6Y1XRR8yDlfC1+0/0YYiL1YZ49mT3sy8ht9anlUFjkmjDwZHjU4RFqOOB GLuYFu8IZHUjJjIj66N7Uoh637nwweB3nRAz7oljxadoObHJYF9QKPOieKUhlMPsvKzqIsne9 calA+g1cjMA+pqunEu/Rl3w9qsoIOKxkftKrd4OXUb7dw8kKfOMb2ylMvr8YX8BJUyjOd4Pwo kseROT8aoNyXQqVOUhSg+htrK8EM55YPXkmWzrYhppx9wnF4O8dJ2aXW17zhsXIRHUMFD4FS/ rfdhe2Ohmtyx8TPeokxs/aM/zhbug4vXh6v8ip0Yr61tQzqeSUWApcpkNBJvGxq1e0gXaLtwm O6lwKE3asN+3A4FQI07os8gEs55qIZORJKGcnqn1dIPRGMtjbAKgxd0HB7FDMG3lB50fxe+mw XQhSvPp4/KvNjOz3VYpRVWUJ9mmxNldkbLBJRvFZelTDq1fbIaJ1cRpIf2ks+C+qzrptrOH4v OrRZ1c3e1gnV5FOnzMKhm3YSXBEWzG/2oy8kG2kNN+ocWwgB0aKuhoKViShlI25x4q+bb60KX FlTHNPX4xjKmorcqtyY6xLEjklaI1sImc9glp/yKhaO8M= X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, 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: Harald Anlauf via Gcc-patches From: Harald Anlauf Reply-To: Harald Anlauf 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?1756661699638175668?= X-GMAIL-MSGID: =?utf-8?q?1756661699638175668?= Dear all, the fix for PR108527 came with a testcase that revealed a latent bug with array sections and invalid array declarations. The ICE first popped up on powerpc64-linux-gnu (big endian), but the issue was not so clear as such on x86_64-pc-linux-gnu, as it did not show up e.g. in valgrind. The traceback provided by Bill provided the right hints, after which the fix became trivial and obvious. Regtested on x86_64-pc-linux-gnu and confirmed on powerpc64-linux-gnu by Bill in the PR. Pushed as: https://gcc.gnu.org/g:88a2a09dd4529107e7ef7a6e7ce43acf96457173 Thanks, Harald diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc index 3036b1be60f..c295721b9d6 100644 --- a/gcc/fortran/expr.cc +++ b/gcc/fortran/expr.cc @@ -1552,7 +1552,11 @@ find_array_section (gfc_expr *expr, gfc_ref *ref) lower = ref->u.ar.as->lower[d]; upper = ref->u.ar.as->upper[d]; - if (!lower || !upper) + if (!lower || !upper + || lower->expr_type != EXPR_CONSTANT + || upper->expr_type != EXPR_CONSTANT + || lower->ts.type != BT_INTEGER + || upper->ts.type != BT_INTEGER) { t = false; goto cleanup; diff --git a/gcc/testsuite/gfortran.dg/pr108527.f90 b/gcc/testsuite/gfortran.dg/pr108527.f90 index c97ba3111cb..804514810ac 100644 --- a/gcc/testsuite/gfortran.dg/pr108527.f90 +++ b/gcc/testsuite/gfortran.dg/pr108527.f90 @@ -4,7 +4,7 @@ program p integer, parameter :: a((2.)) = [4,8] ! { dg-error "must be of INTEGER type" } - integer(a(1:1)) :: b ! { dg-error "out of bounds" } + integer(a(1:1)) :: b ! { dg-error "Unclassifiable statement" } end ! { dg-prune-output "Parameter array" }