diff mbox

PR fortran/68054 -- PROTECTED in modules only

Message ID 20151024175059.GA28261@troutmask.apl.washington.edu
State New
Headers show

Commit Message

Steve Kargl Oct. 24, 2015, 5:50 p.m. UTC
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  <kargl@gcc.gnu.org>

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

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

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

Comments

Mikael Morin Oct. 24, 2015, 8:30 p.m. UTC | #1
Le 24/10/2015 19:50, Steve Kargl a écrit :
> 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?
>
OK. Thanks.

Mikael
diff mbox

Patch

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