From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 53161 invoked by alias); 20 Apr 2019 19:18:51 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 53145 invoked by uid 89); 20 Apr 2019 19:18:51 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00,KAM_NUMSUBJECT autolearn=no version=3.3.1 spammy=withdrawal, interference, CONTAINS, H*f:sk:9E0F69D X-HELO: troutmask.apl.washington.edu Received: from troutmask.apl.washington.edu (HELO troutmask.apl.washington.edu) (128.95.76.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 20 Apr 2019 19:18:50 +0000 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id x3KJIlUm003945 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sat, 20 Apr 2019 12:18:47 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id x3KJIk9U003944; Sat, 20 Apr 2019 12:18:46 -0700 (PDT) (envelope-from sgk) Date: Sat, 20 Apr 2019 19:51:00 -0000 From: Steve Kargl To: "Dominique =?iso-8859-1?Q?d'Humi=E8res?=" Cc: gfortran , gcc-patches Subject: Re: [PATCH] PR fortran/90166 -- check F2018:C1547 Message-ID: <20190420191846.GA3913@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu References: <9E0F69D4-B2B3-4B76-B112-F493AE5ED045@lps.ens.fr> <20190420165734.GA3285@troutmask.apl.washington.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190420165734.GA3285@troutmask.apl.washington.edu> User-Agent: Mutt/1.11.2 (2019-01-07) X-SW-Source: 2019-04/txt/msg00831.txt.bz2 On Sat, Apr 20, 2019 at 09:57:34AM -0700, Steve Kargl wrote: > On Sat, Apr 20, 2019 at 05:38:34PM +0200, Dominique d'Humières wrote: > > > > The changes in gfortran.dg/submodule_22.f08 look weird: > > (1) is the error in the CONTAINS of a SUBMODULE invalid? > > From > > > > * decl.c (in_module_or_interface): New function to check that the > > current state is in a module, submodule, or interface. > > > > it should not, should it? > > > > (2) left over? > > + > > +found outside of a module > > > > It's a sequence of run-on errors. The first statement in > the original code is rejected with a syntax error. When > that happenrs gfc_current_state() is not COMP_MODULE, > COMP_SUBMODULE, or COMP_INTERFENCE. The next line has > the MODULE prefix, and the new check finds that it > occurs outside of MODULE, SUBMODULE, and INTERFERENCE, > so a new error occurs. The remaining errors are then > found to be bogus assignments. My conclusion, if the > first error is fixed, then the run-on errors don't > happen. > > If you rather fix the problems with '! dg-options "-fmax-errors=1"' > I'm fine with that. > Just to follow up. If you use a debugger, one finds (gdb) b decl.c:6130 (gdb) c Continuing. /safe/sgk/gcc/gccx/gcc/testsuite/gfortran.dg/submodule_22.f08:41:23: 41 | submodule (mtop:submod:subsubmod) subsubsubmod ! { dg-error "Syntax error in SUBMODULE statement" } | 1 Error: Syntax error in SUBMODULE statement at (1) This is the original error. Note it is a syntax error. gfortran does nothing with this statement (gdb) c we reach the point where the new error will be issued. (gdb) p gfc_state_stack->state $2 = COMP_CONTAINS This is the CONTAINS in the submodule. (gdb) p gfc_state_stack->previous->state $3 = COMP_PROGRAM This state fine here, because the syntax rejects the submodule statement. So, the code looks like (from memory...) [program main implicitly included here] contains module subroutine foo x = 2 y = 3 end submodule The module prefix cannot appear in the subroutine statement. The new error rejects it. So, now you have 2 assignments in after a contains statement. The program now looks like contains x = 2 y = 3 end submodule Well, you cannot do an assignment, so two additional error messages are emitted. So, now we come to a program of the form [program main implicitly included here] end submodule gfortran is expecting an END [PROGRAM] statement. Is this clear or do you want me to withdrawal the patch? -- Steve