The attached patch fixes an ICE that occurs when gfortran 
is not expecting a PROTECTED attribute.  Built and tested
on x86_64-*-freebsd.  OK to commit?


2015-10-24  Steven G. Kargl  <ka...@gcc.gnu.org>

        PR fortran/68054
        * decl.c (match_attr_spec): PROTECTED can only be a module.

2015-10-24  Steven G. Kargl  <ka...@gcc.gnu.org>

        PR fortran/68054
        * gfortran.dg/pr68054.f90: New test.

-- 
Steve
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c	(revision 229288)
+++ gcc/fortran/decl.c	(working copy)
@@ -3957,7 +3957,9 @@ match_attr_spec (void)
 	  break;
 
 	case DECL_PROTECTED:
-	  if (gfc_current_ns->proc_name->attr.flavor != FL_MODULE)
+	  if (gfc_current_state () != COMP_MODULE
+	      || (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/pr68054.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr68054.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/pr68054.f90	(working copy)
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! PR fortran/68054
+! Original code contributed by Gerhard Steinmetz
+! gerhard dot steinmetz dot fortran at t-online dot de
+!
+!program p
+   real, protected :: x   ! { dg-error "only allowed in specification" }
+end

Reply via email to