This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Fortran,patch] Fix ICE on invalid code (PR29755)


:ADDPATCH fortran:

The problem occurs in decl.c's variable_decl:

   if (current_ts.type == BT_DERIVED
        && gfc_current_ns->proc_name->attr.if_source == IFSRC_IFBODY

If (gfc_current_ns->proc_name == NULL) this produces an ICE.
In my case this happened because the subroutine name in the interface
was the same as the program name.

Ok for trunk and 4.2?

Bootstrapped and regression tested on x86_64-unknown-linux-gnu (openSUSE
10.2beta2).
(Trunk only. Before a 4.2 check in I would also do the bootstrap and
regression test for 4.2.)

Tobias
fortran/
2007-11-08  Tobias Burnus  <burnus@net-b.de>

	PR fortran/29755
	* decl.c (variable_decl): Fix ICE.

testsuite/
2007-11-08  Tobias Burnus  <burnus@net-b.de>

	PR fortran/29755
	* gfortran.dg/dbl_name.f90: Add.

Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c	(revision 118545)
+++ gcc/fortran/decl.c	(working copy)
@@ -1213,13 +1213,20 @@
       goto cleanup;
     }
 
+  if (gfc_current_ns->proc_name == NULL)
+    {
+      m = MATCH_ERROR;
+      goto cleanup;
+    }
+
   /* An interface body specifies all of the procedure's characteristics and these
      shall be consistent with those specified in the procedure definition, except
      that the interface may specify a procedure that is not pure if the procedure
      is defined to be pure(12.3.2).  */
   if (current_ts.type == BT_DERIVED
 	&& gfc_current_ns->proc_name->attr.if_source == IFSRC_IFBODY
--- /dev/null	2006-10-21 23:34:46.000000000 +0200
+++ gcc/testsuite/gfortran.dg/dbl_name.f90	2006-11-07 23:21:57.000000000 +0100
@@ -0,0 +1,16 @@
+! { dg-do compile }
+! { dg-shouldfail "same name of program and subroutine" }
+! Tests whether ICE occurs when using the same name
+! for a subroutine as for the program
+! PR fortran/29755
+program foo
+  type myType
+    integer :: i
+  end type myType
+  interface
+    subroutine foo(x)! { dg-error "PROGRAM attribute conflicts with PROCEDURE" }
+      type(myType) :: i! { dg-error "Unclassifiable statement" }
+    end subroutine foo ! { dg-error "Expecting END INTERFACE statement" }
+  end interface
+  call foo() ! { dg-error "PROGRAM attribute conflicts with PROCEDURE" } 
+end program foo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]