Bug 24549 - [4.1 only] ICE with invalid pseudo-declaration statement
Summary: [4.1 only] ICE with invalid pseudo-declaration statement
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.1.1
Assignee: Francois-Xavier Coudert
URL: http://gcc.gnu.org/ml/fortran/2006-05...
Keywords: ice-on-invalid-code, patch
: 27487 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-10-26 21:31 UTC by Harald Anlauf
Modified: 2006-05-11 21:39 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.2.0 4.1.1
Known to fail:
Last reconfirmed: 2006-05-10 09:07:27


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Harald Anlauf 2005-10-26 21:31:10 UTC
Hi,

the IMPORT statement of Fortran2003 is not yet implemented.
Trying to use it provokes an ICE:

module gfcbug29_import
  integer, parameter :: dp = kind (1d0)

  interface
     subroutine foo (x)
       import :: dp
       real (kind=dp) :: x
     end subroutine foo
  end interface

end module gfcbug29_import


% gfortran -c -std=f2003 gfcbug29.f90
 In file gfcbug29.f90:6

       import :: dp
      1
Error: Unclassifiable statement at (1)
gfcbug29.f90:0: internal compiler error: Segmentation fault

See the Fortran2003 draft, tables 2.1, 2.2, and section 12.3.2.1
about interface blocks.

Cheers,
-ha
Comment 1 Andrew Pinski 2005-10-27 23:13:51 UTC
Confirmed.
Comment 2 Tobias Schlüter 2005-11-07 12:58:10 UTC
I'm marking this ice-on-invalid-code, as it is not valid Fortran 95 and the bug is unrelated to the use of IMPORT, the following ICEs the same way:
  module gfcbug29_import
  interface
     subroutine foo (x)
       something :: dp
       real (kind=dp) :: x
     end subroutine foo
  end interface
end module gfcbug29_import
Comment 3 Andrew Pinski 2006-01-09 22:35:39 UTC
This is weird as I cannot reproduce it on powerpc-darwin but can on x86_64-linux-gnu.
Comment 4 Francois-Xavier Coudert 2006-05-10 09:07:26 UTC
I can reproduce this ICE with mainline on i686-linux. I propose the following patch:

Index: parse.c
===================================================================
--- parse.c     (revision 113603)
+++ parse.c     (working copy)
@@ -1292,7 +1292,7 @@
 static void
 reject_statement (void)
 {
-
+  gfc_new_block = NULL;
   gfc_undo_symbols ();
   gfc_clear_warning ();
   undo_new_statement ();

(see http://gcc.gnu.org/ml/fortran/2006-05/msg00122.html for details).
Comment 5 Francois-Xavier Coudert 2006-05-10 14:37:33 UTC
*** Bug 27487 has been marked as a duplicate of this bug. ***
Comment 6 Francois-Xavier Coudert 2006-05-10 14:51:40 UTC
Subject: Bug 24549

Author: fxcoudert
Date: Wed May 10 14:51:26 2006
New Revision: 113671

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113671
Log:
	PR fortran/24549
	* parse.c (reject_statement): Clear gfc_new_block.
	* gfortran.dg/error_recovery_1.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/error_recovery_1.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/parse.c
    trunk/gcc/testsuite/ChangeLog

Comment 7 Harald Anlauf 2006-05-10 21:53:03 UTC
(In reply to comment #5)
> *** Bug 27487 has been marked as a duplicate of this bug. ***

Well, first of all I have to admit that I am only a Fortran user.
But PR 27487 is only a duplicate because Tobias changed the
subject of my original entry, which was a request for the
implementation of F2003 IMPORT.

FX: Fixing gfortran's error recovery is not the answer to this PR,
but to the other one.  For this reason it seems more reasonable
to change the status of PR 27487 back and move your patch there.
Next, the subject of this PR should be reset to my original one,
as IMPORT is required for F2003 support, see PR 20585.
Comment 8 Francois-Xavier Coudert 2006-05-11 06:08:59 UTC
(In reply to comment #7)
> FX: Fixing gfortran's error recovery is not the answer to this PR,
> but to the other one.

Yes, I know. Since this PR was already used for tracking the ICE, I planned on opening a new PR for the F2003 IMPORT feature when this one was resolved. It is now filed as PR 27546 (and you're in the CC list).
Comment 9 Francois-Xavier Coudert 2006-05-11 21:39:17 UTC
Subject: Bug 24549

Author: fxcoudert
Date: Thu May 11 21:39:06 2006
New Revision: 113713

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113713
Log:
	PR fortran/20460
	PR fortran/24549
	* parse.c (reject_statement): Clear gfc_new_block.
	* resolve.c (gfc_resolve_index): Make REAL array indices a
	GFC_STD_LEGACY feature.
	* gfortran.dg/error_recovery_1.f90: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/error_recovery_1.f90
      - copied unchanged from r113671, trunk/gcc/testsuite/gfortran.dg/error_recovery_1.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/fortran/resolve.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog

Comment 10 Francois-Xavier Coudert 2006-05-11 21:39:52 UTC
Fixed on mainline and 4.1.