Regression tested on trunk. OK to commit?
Subject says it all.
2015-05-XX Steven G. Kargl <[email protected]>
PR fortran/66052
* decl.c(gfc_match_protected): Prevent dereference of NULL pointer.
2015-05-XX Steven G. Kargl <[email protected]>
PR fortran/66052
* gfortran.dg/protected_9.f90: New test.
--
Steve
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c (revision 223094)
+++ gcc/fortran/decl.c (working copy)
@@ -6968,7 +6968,8 @@ gfc_match_protected (void)
gfc_symbol *sym;
match m;
- if (gfc_current_ns->proc_name->attr.flavor != FL_MODULE)
+ if (gfc_current_ns->proc_name
+ && gfc_current_ns->proc_name->attr.flavor != FL_MODULE)
{
gfc_error ("PROTECTED at %C only allowed in specification "
"part of a module");
Index: gcc/testsuite/gfortran.dg/protected_9.f90
===================================================================
--- gcc/testsuite/gfortran.dg/protected_9.f90 (revision 0)
+++ gcc/testsuite/gfortran.dg/protected_9.f90 (working copy)
@@ -0,0 +1,16 @@
+! { dg-do compile }
+! PR fortran/66052
+!
+!
+! Original code from Gerhard Steinmetz
+! <gerhard dot steinmetz dot fortran at t-online dot de>
+module a
+ contains
+ protected x ! { dg-error "Unexpected attribute declaration statement" }
+end module a
+
+program p
+ contains
+ protected x ! { dg-error "Unexpected attribute declaration statement" }
+end
+