From patchwork Tue Sep 20 20:57:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 1326 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp1639900wrt; Tue, 20 Sep 2022 13:58:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7sDYyl0rKd5FSiNuTU4RYZvEVU5t2lDxZDHC6LP4AyKuzGMwPBdE/6FUWej48KiM+YnHQ6 X-Received: by 2002:a17:907:9714:b0:77b:e7a8:2f66 with SMTP id jg20-20020a170907971400b0077be7a82f66mr18799822ejc.107.1663707520636; Tue, 20 Sep 2022 13:58:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663707520; cv=none; d=google.com; s=arc-20160816; b=ES4SpL+oHh7wU/qQq4+Suk2a6QThJIXkTNyftOugukT+Aap+PZVZYWwWgaJykyHG/A N5e5nmWbaqGqD6Y7Jkg/7aB1GlOwIRr4K0S2n80XPdMvxVcPqF77HlxZo6nGzuiTIT3a hmm5hLMN2Twe/JJFov1pSvlq7xuMKYxfi+JKYH8V7cvNXcm2JhhCXMU+aXuMSnsfOhsk xBsW9tA/9lAKwE/a4IM7HncQZqFAaIYgikgalsq5YrR5NPmTdD1axFHw4OZY5YPKRM+/ k+Wbif7BCQ2/6HU5PK1I/PkdQEO626+f5L1LtwY4q7E0T8IiaaDZedMJnLnSDxsOVvRG wbHg== 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:sensitivity :importance:date:subject:to:message-id:mime-version:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=S4I48uRWUmNSUXeD0vxrAW6oNhtZZsyP6bVO45T15xI=; b=X1eBUcpJMZzA+GRIKFEjKNSo4HIhqUpNM7nf/O16Hor9ILhJPBxYCsg2R1RM8BeEz/ rU/cUgzzbYTKfKf27c6RQTIChEt1VFzIb7Vx1264oA4VRUZos+dKZeUmwSDyWvGq7gzZ drKiw9+orFyNjgMpmZNAZN+OVAPWP5X8u2kg3VteJKN8JqPm1BSvS5MOSAiUnH6piFMQ zO8s4T+obDwuk7oXblwppHTeaP8mDFtbhrypa8Lbtrm7CIEpIspatNI4ELQSibc4zTpQ AFjzVLHAnrzRXJPNDDNeUzzLidYQlQMp/kj/Sg2EzWrCiVx+CdOB6ofjUJTEiYtQo7/4 1ycQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=gP8DeIOV; 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 e13-20020a1709062c0d00b00780dd2b1fb3si554956ejh.867.2022.09.20.13.58.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 13:58:40 -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=pass header.i=@gcc.gnu.org header.s=default header.b=gP8DeIOV; 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 80B1D3858C55 for ; Tue, 20 Sep 2022 20:58:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 80B1D3858C55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663707516; bh=S4I48uRWUmNSUXeD0vxrAW6oNhtZZsyP6bVO45T15xI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=gP8DeIOVBAGBdILkx1NynvoyXvOoeQib7gzKz1xqLvbr7IfuEm/xHcw/2jzpouMIo L4ARfqVe4+VhnpDgxwkmSZED/70I26x4Zi2muknoPCma77MW2o2/5AAsZE/lY7x/NE lsdG15tqy/BRzDa75c0GS8seUu90Jdq7nbIZiCEg= 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.17.20]) by sourceware.org (Postfix) with ESMTPS id 4E4D93858C55; Tue, 20 Sep 2022 20:57:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4E4D93858C55 X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [93.207.88.67] ([93.207.88.67]) by web-mail.gmx.net (3c-app-gmx-bap12.server.lan [172.19.172.82]) (via HTTP); Tue, 20 Sep 2022 22:57:41 +0200 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH, committed] Fortran: error recovery on invalid ARRAY argument to FINDLOC [PR106986] Date: Tue, 20 Sep 2022 22:57:41 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:W0gKxwuJkm6InGYc8FHbbTFvAEnFtvfokLOTKddlThRFLLV9xbEPWsXeoa66U+koVz/6R vo+IqaxY/+7kjNkV3rAn8OSK6F6hgYnzne67Yjt6SJOkLA/w9tKLBXfFvVTqvBd/dcqyMm5dsAdJ cV7IOX12rFw7vY3lTapv3AEDf9SHrEd8hhEAi+TF3y8dxrHIqG6BHTVdG6s3rJnuk85BJd/JvVqa u+0559vh+ngeNqm1aMPVbonreBN7MsIjbmSU7vI8Qb1Juf8OswIjvworNHRYjSkumBbyZIBmUiHz jc= X-UI-Out-Filterresults: notjunk:1;V03:K0:CaNgXXVljgU=:Njsnw9NC7aWk6dEIEQzaRb yq6neuAz2n2Q+BbWwt9Arf5TgByFhZB4J52IDzgv10oUr7oobSuL4P4uWcm/HJiyBs67mQ9Eu niqzwHCl1hD+/o1RMjYIu6QMpVVudEgie7Hix75dDWaQRv6v8rcJzEHHDT1bOxTcdv41V1wHy avAyVoQNh302CElsffVU/RCNSzi9jddue3BkxdIvgp6EHxJMZ2xutQRS18cCM0ANB1FyvS8C9 oBfgzI6avQ1u92tBuaNdkeqhRkwEBKLvagtDc/8kHLPDc4RTsGQT83W2HpFb5o4g64moci8// BMzUO3Bqvbq2gSyAMKgBwp/8U/Y9VBICopa/lY50At6zGBR8t4a8AXr0UT2J2FSlqjaljal7n rNvDZWSQ7O+SelUFC1lcGSFiIIXZhWOn4LdDMyEWQWcs3dH6IH9na+lq/2YFnGjAiL8XMe4n9 p1k81M4F9CZ7IGfz4pDEIcxH+BEVsWXYWrnGTbqhcT7F0bPYoOYKcfgsVNWua+ge5jgeiU6p+ 9YUUk0NX+A0h6iLuC/YNCIFzqzoQtR45s0afbfCY7JGtPC+jsD4kbbiKlsc34/7SjIJf+1Q+0 UVW4kVSJnUAAllOcpUZp+0A9OZsgla4hJQi2SK5/5LsV1ptTdox7Kpa2uJZ+9p4MkMv1CrKdG hFXPEoBqR9PxSxmHKboQToB+ZaNAjyKeIvHNGB0svktnzBCvwoUq1d0DBbn+02h6W7hWQenaI TJUXStCzqnFVRlWLu9QMj/Eb0Fkz+ftHiYVtBx+7HicOxa79IvYrFUUnPbU= X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, 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?1744523777076881272?= X-GMAIL-MSGID: =?utf-8?q?1744523777076881272?= Dear all, we ICE'd in the simplification of FINDLOC when the passed ARRAY argument had an invalid declaration. The reason was a reference to array->shape which was NULL. Obvious solution: then just don't attempt to simplify. Regtested on x86_64-pc-linux-gnu and pushed to mainline as https://gcc.gnu.org/g:5976fbf9d5dd9542fcb82eebb2185886fd52d000 The PR is marked as a 10/11/12/13 regression, thus I plan to backport. Thanks, Harald From 5976fbf9d5dd9542fcb82eebb2185886fd52d000 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Tue, 20 Sep 2022 22:41:48 +0200 Subject: [PATCH] Fortran: error recovery on invalid ARRAY argument to FINDLOC [PR106986] gcc/fortran/ChangeLog: PR fortran/106986 * simplify.cc (gfc_simplify_findloc): Do not try to simplify intrinsic FINDLOC when the ARRAY argument has a NULL shape. gcc/testsuite/ChangeLog: PR fortran/106986 * gfortran.dg/pr106986.f90: New test. --- gcc/fortran/simplify.cc | 1 + gcc/testsuite/gfortran.dg/pr106986.f90 | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr106986.f90 diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc index 140c17721a7..c0fbd0ed7c2 100644 --- a/gcc/fortran/simplify.cc +++ b/gcc/fortran/simplify.cc @@ -5895,6 +5895,7 @@ gfc_simplify_findloc (gfc_expr *array, gfc_expr *value, gfc_expr *dim, bool back_val = false; if (!is_constant_array_expr (array) + || array->shape == NULL || !gfc_is_constant_expr (dim)) return NULL; diff --git a/gcc/testsuite/gfortran.dg/pr106986.f90 b/gcc/testsuite/gfortran.dg/pr106986.f90 new file mode 100644 index 00000000000..a309b25d181 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr106986.f90 @@ -0,0 +1,8 @@ +! { dg-do compile } +! PR fortran/106986 - ICE in simplify_findloc_nodim +! Contributed by G.Steinmetz + +program p + integer, parameter :: a(:) = [1] ! { dg-error "deferred shape" } + print *, findloc (a, 1) +end -- 2.35.3