Bug 27553 - [4.1 only] Testsuite ICE with -Wunused-labels
Summary: [4.1 only] Testsuite ICE with -Wunused-labels
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.1.2
Assignee: Francois-Xavier Coudert
URL:
Keywords: error-recovery, ice-on-invalid-code, patch
Depends on:
Blocks:
 
Reported: 2006-05-11 11:34 UTC by Francois-Xavier Coudert
Modified: 2006-05-29 22:51 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.2.0 4.1.1
Known to fail:
Last reconfirmed: 2006-05-11 18:46:22


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Francois-Xavier Coudert 2006-05-11 11:34:46 UTC
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.
Comment 1 Francois-Xavier Coudert 2006-05-11 18:46:22 UTC
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
        {
Comment 2 Steve Kargl 2006-05-11 19:23:33 UTC
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.

Comment 3 Francois-Xavier Coudert 2006-05-11 21:37:19 UTC
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

Comment 4 Francois-Xavier Coudert 2006-05-11 21:38:11 UTC
Commited on mainline.
Comment 5 Francois-Xavier Coudert 2006-05-17 12:04:28 UTC
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

Comment 6 Francois-Xavier Coudert 2006-05-17 12:07:05 UTC
Fixed on 4.1 and mainline.