Patchwork [Fortran,committed] PR57435 - Avoid ICE due to deref of a null pointer

login
register
mail settings
Submitter Tobias Burnus
Date May 28, 2013, 3:21 p.m.
Message ID <51A4CB6A.7030307@net-b.de>
Download mbox | patch
Permalink /patch/246894/
State New
Headers show

Comments

Tobias Burnus - May 28, 2013, 3:21 p.m.
See PR for details. A rather obvious fix by Dominique. Thanks to him and 
to the bug reporter.

Committed to the trunk as Rev. 199382 after building+regtesting the 
patch on x86-64-gnu-linux.

Tobias

Patch

2013-05-28  Dominique d'Humieres  <dominiq@lps.ens.fr>

	PR fortran/57435
	* module.c (check_for_ambiguous): Avoid null pointer deref.

2013-05-28  Tobias Burnus  <burnus@net-b.de>

	PR fortran/57435
	* testsuite/gfortran.dg/use_29.f90: New.

diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c
index 9486b28..c9ba0e2 100644
--- a/gcc/fortran/module.c
+++ b/gcc/fortran/module.c
@@ -4530,7 +4530,7 @@  check_for_ambiguous (gfc_symbol *st_sym, pointer_info *info)
   module_locus locus;
   symbol_attribute attr;
 
-  if (st_sym->name == gfc_current_ns->proc_name->name)
+  if (gfc_current_ns->proc_name && st_sym->name == gfc_current_ns->proc_name->name)
     {
       gfc_error ("'%s' of module '%s', imported at %C, is also the name of the "
 		 "current program unit", st_sym->name, module_name);
--- /dev/null	2013-05-28 12:48:31.906094883 +0200
+++ gcc/gcc/testsuite/gfortran.dg/use_29.f90	2013-05-28 16:18:14.997931054 +0200
@@ -0,0 +1,15 @@ 
+! { dg-do compile }
+!
+! PR fortran/57435
+!
+! Contributed by Lorenz Hüdepohl
+!
+module precision
+end module precision
+  contains
+  use precision     ! { dg-error "Unexpected USE statement in CONTAINS section" }
+module stressten_rt ! { dg-error "Unexpected MODULE statement in CONTAINS section" }
+  use precision     ! { dg-error "Unexpected USE statement in CONTAINS section" }
+  implicit none     ! { dg-error "Unexpected IMPLICIT NONE statement in CONTAINS section" }
+
+! { dg-error "Unexpected end of file" "" { target "*-*-*" } 0 }