public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR fortran/68054 -- PROTECTED in modules only
@ 2015-10-24 19:08 Steve Kargl
  2015-10-24 20:44 ` Mikael Morin
  0 siblings, 1 reply; 2+ messages in thread
From: Steve Kargl @ 2015-10-24 19:08 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 402 bytes --]

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.

-- 
Steve

[-- Attachment #2: pr68054.diff --]
[-- Type: text/x-diff, Size: 1045 bytes --]

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] PR fortran/68054 -- PROTECTED in modules only
  2015-10-24 19:08 [PATCH] PR fortran/68054 -- PROTECTED in modules only Steve Kargl
@ 2015-10-24 20:44 ` Mikael Morin
  0 siblings, 0 replies; 2+ messages in thread
From: Mikael Morin @ 2015-10-24 20:44 UTC (permalink / raw)
  To: Steve Kargl, fortran, gcc-patches

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-10-24 20:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-24 19:08 [PATCH] PR fortran/68054 -- PROTECTED in modules only Steve Kargl
2015-10-24 20:44 ` Mikael Morin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).