From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id 5EE83385840A; Tue, 11 Jul 2023 13:13:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5EE83385840A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-55af0a816e4so2824147a12.1; Tue, 11 Jul 2023 06:13:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689081203; x=1691673203; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=U1PQHFbAiytEUpBWdXZCvXwQCdipzkYQoAXbIk1mtTs=; b=esGxaYj8C/1kebiTUNAXHA6FM/Kl9kff+9fMfMI8NJfQ9+/YCMpgpXzZ8P6QlrfRoY 0NQGuWIlYl0gwkmaguCjmdqY1d7U0lafnnnwMrEtXALYLMTcegO05UKrTarC/tWjS1Q/ AdaHvACNAGrPZWkdEItaB/j/o/Z7xDu8DfLdAaQkz+2opxqP2p++AUz9T39lnlTm9YlD gSN5UdUyGIhoWJFZI40TdIqq0ju15q3nRao7k3c2NoED8OePxy8GrflLSkrr+ncAOvzL tPZmGKU36CBcMKncg8G5+XuD7Df8y7ugr8yd7NdSsbKCvdvZopQWYdOQaYFcAgIsuAs4 WpzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689081203; x=1691673203; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=U1PQHFbAiytEUpBWdXZCvXwQCdipzkYQoAXbIk1mtTs=; b=CzRcLT+zOiZ7hWbHV7iDEKDmYHcsk9qMk4ajaAFx5FIBGSpLI5AQZ6ml9SOZv7k8wS iMXnpRSCj8xVjR/ffkL62FrClplITVXyuFrmRuP+VUY3RcfO/nLYfLLoyoJV02iw+vEL NAEU5+fEDcsN+Dg15Fhb74LqyKLvci1KYsFCIAOhHcGkIIE/OQqBgmVGNhwUdQwTkq20 H7iB75Fnzu5W/2g/sHjD1QMpDHPs6BxknPbuTKStSRRCWRJSc8S5D621ekpDoCYpjWNf tya9AgdOGTZZAQlvQVpF11vrLLUta78DKSLBhgAsov7fOITwL55b1hxposKLbqps7wPk eNhw== X-Gm-Message-State: ABy/qLZDxVURA+lxpidVRT/knDAfuM2E0O+NF4NUwohHUIIYD9LIKSlU 6HjXPvvLWIA0vbGUJdlJssjx4lYFQcr8yRyqghnWhTEu X-Google-Smtp-Source: APBJJlEYPZPh3BoCeXXUTjR7q+6W2wQHiip/cxMQVpe3pm1+pFRUj1/L0aYlqQsb3f+oFXIbXPoNmPVijEFcdtZefrk= X-Received: by 2002:a17:90b:3a88:b0:263:fd88:24bb with SMTP id om8-20020a17090b3a8800b00263fd8824bbmr11123803pjb.40.1689081202672; Tue, 11 Jul 2023 06:13:22 -0700 (PDT) MIME-Version: 1.0 References: <20230711120835.2043753-1-mikael@gcc.gnu.org> In-Reply-To: <20230711120835.2043753-1-mikael@gcc.gnu.org> From: Paul Richard Thomas Date: Tue, 11 Jul 2023 14:13:11 +0100 Message-ID: Subject: Re: [PATCH] fortran: Release symbols in reversed order [PR106050] To: Mikael Morin Cc: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,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 List-Id: Hi Mikhail, That's more than OK by me. Thanks for attacking this PR. I have a couple more of Steve's orphans waiting to be packaged up - 91960 and 104649. I'll submit them this evening.100607 is closed-fixed and 103796 seems to be fixed. Regards Paul On Tue, 11 Jul 2023 at 13:08, Mikael Morin via Fortran wrote: > > Hello, > > I saw the light regarding this PR after Paul posted a comment yesterday. > > Regression test in progress on x86_64-pc-linux-gnu. > I plan to push in the next hours. > > Mikael > > -- >8 -- > > Release symbols in reversed order wrt the order they were allocated. > This fixes an error recovery ICE in the case of a misplaced > derived type declaration. Such a declaration creates nested > symbols, one for the derived type and one for each type parameter, > which should be immediately released as the declaration is > rejected. This breaks if the derived type is released first. > As the type parameter symbols are in the namespace of the derived > type, releasing the derived type releases the type parameters, so > one can't access them after that, even to release them. Hence, > the type parameters should be released first. > > PR fortran/106050 > > gcc/fortran/ChangeLog: > > * symbol.cc (gfc_restore_last_undo_checkpoint): Release symbols > in reverse order. > > gcc/testsuite/ChangeLog: > > * gfortran.dg/pdt_33.f90: New test. > --- > gcc/fortran/symbol.cc | 2 +- > gcc/testsuite/gfortran.dg/pdt_33.f90 | 15 +++++++++++++++ > 2 files changed, 16 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gfortran.dg/pdt_33.f90 > > diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc > index 37a9e8fa0ae..4a71d84b3fe 100644 > --- a/gcc/fortran/symbol.cc > +++ b/gcc/fortran/symbol.cc > @@ -3661,7 +3661,7 @@ gfc_restore_last_undo_checkpoint (void) > gfc_symbol *p; > unsigned i; > > - FOR_EACH_VEC_ELT (latest_undo_chgset->syms, i, p) > + FOR_EACH_VEC_ELT_REVERSE (latest_undo_chgset->syms, i, p) > { > /* Symbol in a common block was new. Or was old and just put in common */ > if (p->common_block > diff --git a/gcc/testsuite/gfortran.dg/pdt_33.f90 b/gcc/testsuite/gfortran.dg/pdt_33.f90 > new file mode 100644 > index 00000000000..0521513f2f8 > --- /dev/null > +++ b/gcc/testsuite/gfortran.dg/pdt_33.f90 > @@ -0,0 +1,15 @@ > +! { dg-do compile } > +! > +! PR fortran/106050 > +! The following used to trigger an error recovery ICE by releasing > +! the symbol T before the symbol K which was leading to releasing > +! K twice as it's in T's namespace. > +! > +! Contributed by G. Steinmetz > + > +program p > + a = 1 > + type t(k) ! { dg-error "Unexpected derived type declaration" } > + integer, kind :: k = 4 ! { dg-error "not allowed outside a TYPE definition" } > + end type ! { dg-error "Expecting END PROGRAM" } > +end > -- > 2.40.1 > -- "If you can't explain it simply, you don't understand it well enough" - Albert Einstein