OK I missed the previous error. However I am still puzzled by (2): + +found outside of a module
Dominique > Le 20 avr. 2019 à 21:18, Steve Kargl <s...@troutmask.apl.washington.edu> a > écrit : > > 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