label_2.f90, from the testsuite, encounters an ICE when compiled with -Wall: $ cat src/label_2.f90 ! { dg-do compile } ! PR fortran/24640. We needed to check that whitespace follows ! a statement label in free form. ! program pr24640 10: a=10 ! { dg-error "character in statement" } end program $ gfortran -c src/label_2.f90 -Wall In file src/label_2.f90:7 10: a=10 ! { dg-error "character in statement" } 1 Error: Non-numeric character in statement label at (1) src/label_2.f90:0: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions.
The ICE is due to -Wunused-labels. We try to issue a warning about the label (already marked as an error because it contains a non-numeric character) being unused, but said label has no locus (because the parser errored out before assigning it. Steve, I'm adding you in the CC list since you were the one who rewrote that codepath a few months ago, IIRC. I propose we strengthen the errorn in that case and also for the "Too many digits" and "Zero is not a valid label", by the following patch: Index: parse.c =================================================================== --- parse.c (revision 113671) +++ parse.c (working copy) @@ -439,6 +439,7 @@ if (!gfc_is_whitespace (c)) gfc_error_now ("Non-numeric character in statement label at %C"); + return ST_NONE; } else {
Subject: Re: Testsuite ICE with -Wunused-labels On Thu, May 11, 2006 at 06:46:22PM -0000, fxcoudert at gcc dot gnu dot org wrote: > The ICE is due to -Wunused-labels. We try to issue a warning about the label > (already marked as an error because it contains a non-numeric character) being > unused, but said label has no locus (because the parser errored out before > assigning it. > > Steve, I'm adding you in the CC list since you were the one who rewrote that > codepath a few months ago, IIRC. > > I propose we strengthen the errorn in that case and also for the "Too many > digits" and "Zero is not a valid label", by the following patch: > > Index: parse.c > =================================================================== > --- parse.c (revision 113671) > +++ parse.c (working copy) > @@ -439,6 +439,7 @@ > if (!gfc_is_whitespace (c)) > gfc_error_now ("Non-numeric character in statement label at %C"); > > + return ST_NONE; > } > else > { > Yes, the above looks correct; otherwise, we fall through to the decode_statement() call.
Subject: Bug 27553 Author: fxcoudert Date: Thu May 11 21:37:10 2006 New Revision: 113712 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113712 Log: PR fortran/27553 * parse.c (next_free): Return instead of calling decode_statement upon error. * gfortran.dg/label_5.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/label_5.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/parse.c trunk/gcc/testsuite/ChangeLog
Commited on mainline.
Subject: Bug 27553 Author: fxcoudert Date: Wed May 17 12:04:17 2006 New Revision: 113854 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113854 Log: PR fortran/27553 * parse.c (next_free): Return instead of calling decode_statement upon error. * gfortran.dg/label_5.f90: New test. Added: branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/label_5.f90 - copied unchanged from r113712, trunk/gcc/testsuite/gfortran.dg/label_5.f90 Modified: branches/gcc-4_1-branch/gcc/fortran/ChangeLog branches/gcc-4_1-branch/gcc/fortran/parse.c branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
Fixed on 4.1 and mainline.