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
2013-05-28 Dominique d'Humieres <domi...@lps.ens.fr>
PR fortran/57435
* module.c (check_for_ambiguous): Avoid null pointer deref.
2013-05-28 Tobias Burnus <bur...@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 }