Bug 27378 - [4.1 only] ICE on unexpected ELSE statement
Summary: [4.1 only] ICE on unexpected ELSE statement
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.1.1
Assignee: Francois-Xavier Coudert
URL:
Keywords: error-recovery, ice-on-invalid-code, monitored, patch
Depends on:
Blocks:
 
Reported: 2006-05-02 09:08 UTC by Volker Reichelt
Modified: 2006-05-08 10:46 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.2.0 4.1.1
Known to fail:
Last reconfirmed: 2006-05-07 16:37:04


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2006-05-02 09:08:47 UTC
The following invalid testcase causes an ICE when compiled with -Wall:

===============
else
===============

The error message is:
 In file bug.f90:1

else
   1
Error: Unexpected ELSE statement at (1)
bug.f90:0: internal compiler error: Segmentation fault


Without -Wall I get:
 In file bug.f90:1

else
   1
Error: Unexpected ELSE statement at (1)
Error: Unexpected end of file in 'bug.f90'

This happens since GCC 4.0.1.
Comment 1 Steven Bosscher 2006-05-02 16:57:17 UTC
Index: parse.c
===================================================================
--- parse.c     (revision 113473)
+++ parse.c     (working copy)
@@ -624,6 +624,7 @@ next_statement (void)
       if (gfc_at_eol ())
        {
          if (gfc_option.warn_line_truncation
+             && gfc_current_locus.lb
              && gfc_current_locus.lb->truncated)
            gfc_warning_now ("Line truncated at %C");

Comment 2 kargls 2006-05-02 19:28:47 UTC
(In reply to comment #1)
> Index: parse.c
> ===================================================================
> --- parse.c     (revision 113473)
> +++ parse.c     (working copy)
> @@ -624,6 +624,7 @@ next_statement (void)
>        if (gfc_at_eol ())
>         {
>           if (gfc_option.warn_line_truncation
> +             && gfc_current_locus.lb
>               && gfc_current_locus.lb->truncated)
>             gfc_warning_now ("Line truncated at %C");
> 

Looks like an "Obviously correct" patch.
Comment 3 Francois-Xavier Coudert 2006-05-07 16:33:41 UTC
Subject: Bug 27378

Author: fxcoudert
Date: Sun May  7 16:33:30 2006
New Revision: 113603

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113603
Log:
	PR fortran/27378
	* parse.c (next_statement): Add check to avoid an ICE when
	gfc_current_locus.lb is not set.

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/parse.c

Comment 4 Francois-Xavier Coudert 2006-05-07 16:37:04 UTC
> Looks like an "Obviously correct" patch.

Commited the "Obviously correct" patch after regtesting on i686-linux.
Comment 5 Francois-Xavier Coudert 2006-05-08 10:43:26 UTC
Subject: Bug 27378

Author: fxcoudert
Date: Mon May  8 10:43:18 2006
New Revision: 113629

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113629
Log:
	PR fortran/27378
	* parse.c (next_statement): Add check to avoid an ICE when
	gfc_current_locus.lb is not set.

Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/fortran/parse.c

Comment 6 Francois-Xavier Coudert 2006-05-08 10:46:46 UTC
Fixed on 4.1 and mainline.