From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by sourceware.org (Postfix) with ESMTPS id 6DEDA3858D1E; Tue, 23 Aug 2022 20:29:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6DEDA3858D1E X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [79.251.11.22] ([79.251.11.22]) by web-mail.gmx.net (3c-app-gmx-bap05.server.lan [172.19.172.75]) (via HTTP); Tue, 23 Aug 2022 22:29:43 +0200 MIME-Version: 1.0 Message-ID: From: Harald Anlauf To: fortran , gcc-patches Subject: [PATCH] Fortran: improve error recovery while simplifying size of bad array [PR103694] Content-Type: multipart/mixed; boundary=rekceb-8a362c0d-5ebb-4a96-b8a7-c4493dadf426 Date: Tue, 23 Aug 2022 22:29:43 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:f2fP64EZmiyd+SZ9wc8WuXGHlDPMO7JlL6XqBdrK2tFUHjKca6I9DnVtqri/ZNjzSkBaw VAXFRbqLe6mAL6PKz6lWwtyw7+ZLNyH7CD3K/VOXwt0v3YRR0iXlFNHeYE66N7uINKrWKcWJE73N rL5ccsPb+FrAK+Ig3aATf2vjctll88j+j1PS1MQO/GzoP69VkfrrVOl1ScZYKVnABlabckVPMksb fRGuV2PM/KaDbBDPUI4t+Y/AAWVIK7R2mq1IbsFD5nz7DT4gdn4ELC6qVVHpu5Lvoo1u3jLKxL70 Vs= X-UI-Out-Filterresults: notjunk:1;V03:K0:SXEfE3nEqpM=:KwI9QeHZoHbR0m2IElAZpB XjbQDTZqqmfSw4luzl1t4ihhRv8bfBFoaF4TiSr4g6bZOb2bZYmUY82IhzGFlc1vurNUdp1Iv pF43QO6E+upukw7CiUtoKHzS7M0m7y7gggASBLM/kNT0cqOrcFPqrxfBEaFQJ/AJPFa52jhB7 +srnOqkNMMpQPlVeDl1W+isV4yXXiQUqjp0kxzsnvJ+iX0gpUP0aHRqyPYmc67HOLlQ2ipvMk hETQO6eG8WlpMCW4VuuBQM4tvi2O3wJjnekvlKetPUXJTnp3k0gFnJwU2uyVZPZiNOy802trO mVJLrnEUYJiGjttv4c+PLRljk+oCNdne9lWbfRdQ0oG6NVLsi15HsIK7efAK7zJ7ufpv02jk1 sm6zXpLq07IJuqIH6dkbRXQS6GEZGHbNbUjNBD3bga5Efcx2uCtrEtJCssxSHdpdmTT8tVoRG 5dvCtHkVUBgHoBEQHlE440ii0hBBlsYL5VRltQKsRRSTcszXBnqaxl67dFgmDWUtrKBY3X9mC 3b2JTZzXa/5kvGzitkqOLVYWA0KZKIMDxgvgsMVkrr2Ad3bpoH2r+vcn+BCVlq7+xd2m14W1l IoGJoPiLEJ0dJVNbwfOhpeHE3AsakADCqyEOJV+yTeJYrp1k/OSbET5EvuTBPXGgJK2+pRc2v bwInzK4ZZUDRSuqbGYAJIGgN+saPGn94FIg2t+4MhtwB0v0zLm5JeCV9ANihJdiCRl+IwrMET ixAXwTJ6+4fxcP5ekS4rK+I/4NAWZStciWBa5zxxMhmT5ByWjDTl9KdICPY= X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Aug 2022 20:29:48 -0000 --rekceb-8a362c0d-5ebb-4a96-b8a7-c4493dadf426 Content-Type: text/plain; charset=UTF-8 Dear all, the simplification of the size of an array with a bad decl should not be successful. Improve the error recovery for such a situation. The patch is nearly obvious. I therefore intend to commit it in the next few days unless someone comes up with a better solution. Regtested on x86_64-pc-linux-gnu. The PR is marked as a 12/13 regression. Will therefore commit to both. Thanks, Harald --rekceb-8a362c0d-5ebb-4a96-b8a7-c4493dadf426 Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fortran-improve-error-recovery-while-simplifying-siz.patch Content-Transfer-Encoding: quoted-printable =46rom d306c0b171e502e3c87b92b6bc63b532f734e754 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Tue, 23 Aug 2022 22:16:14 +0200 Subject: [PATCH] Fortran: improve error recovery while simplifying size of= bad array [PR103694] gcc/fortran/ChangeLog: PR fortran/103694 * simplify.cc (simplify_size): The size expression of an array cannot be simplified if an error occurs while resolving the array spec. gcc/testsuite/ChangeLog: PR fortran/103694 * gfortran.dg/pr103694.f90: New test. =2D-- gcc/fortran/simplify.cc | 5 +++-- gcc/testsuite/gfortran.dg/pr103694.f90 | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr103694.f90 diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc index f992c31e5d7..bc178d54891 100644 =2D-- a/gcc/fortran/simplify.cc +++ b/gcc/fortran/simplify.cc @@ -7536,8 +7536,9 @@ simplify_size (gfc_expr *array, gfc_expr *dim, int k= ) } for (ref =3D array->ref; ref; ref =3D ref->next) - if (ref->type =3D=3D REF_ARRAY && ref->u.ar.as) - gfc_resolve_array_spec (ref->u.ar.as, 0); + if (ref->type =3D=3D REF_ARRAY && ref->u.ar.as + && !gfc_resolve_array_spec (ref->u.ar.as, 0)) + return NULL; if (dim =3D=3D NULL) { diff --git a/gcc/testsuite/gfortran.dg/pr103694.f90 b/gcc/testsuite/gfortr= an.dg/pr103694.f90 new file mode 100644 index 00000000000..3ed8b2088da =2D-- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr103694.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! PR fortran/103694 - ICE in gfc_conv_expr_op +! Contributed by G.Steinmetz + +subroutine s + type t + integer :: a(2) + end type + type(t) :: x((0.)/0) + integer :: n =3D size(x(1)%a) ! { dg-error "does not reduce to a consta= nt expression" } +end =2D- 2.35.3 --rekceb-8a362c0d-5ebb-4a96-b8a7-c4493dadf426--