public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR fortran/67885 -- PARAMETER needs to be marked in BLOCK
@ 2015-10-26 19:58 Steve Kargl
  2015-10-27  7:15 ` Thomas Koenig
  0 siblings, 1 reply; 2+ messages in thread
From: Steve Kargl @ 2015-10-26 19:58 UTC (permalink / raw)
  To: fortran, gcc-patches

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

When an specification statement in a BLOCK construct has a
PARAMETER attribute, gfortran currently discards the entity.
This patch marks PARAMETER entity if in a BLOCK.  I'm not
complete convince that this is the right fix, but it does
allow the testcase to compile and run.  Built and tested
on x86_64-*-freebsd.  OK to commit (if not no one has a
better patch)?

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

	PR fortran/67885
	* trans-decl.c (generate_local_decl): Mark PARAMETER entities in
	BLOCK construct.

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

	PR fortran/67885
	* gfortran.dg/pr67885.f90: New test.

-- 
Steve

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

Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c	(revision 229390)
+++ gcc/fortran/trans-decl.c	(working copy)
@@ -5217,6 +5217,16 @@ generate_local_decl (gfc_symbol * sym)
 			  "Unused parameter %qs which has been explicitly "
 			  "imported at %L", sym->name, &sym->declared_at);
 	}
+
+      if (sym->ns
+	  && sym->ns->parent
+	  && sym->ns->parent->code
+	  && sym->ns->parent->code->op == EXEC_BLOCK)
+	{
+	  if (sym->attr.referenced)
+	    gfc_get_symbol_decl (sym);
+	  sym->mark = 1;
+	}
     }
   else if (sym->attr.flavor == FL_PROCEDURE)
     {
Index: gcc/testsuite/gfortran.dg/pr67885.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr67885.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/pr67885.f90	(working copy)
@@ -0,0 +1,12 @@
+! { dg-do run }
+! PR fortran/67885
+! Original code contributed by Gerhard Steinmetz
+! gerhard dot steinmetz dot fortran at t-online dot de
+program p
+   block
+      integer, parameter :: a(2) = [1, 2]
+      integer :: x(2)
+      x = a
+      if (x(1) /= 1) call abort
+   end block
+end

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

* Re: [PATCH] PR fortran/67885 -- PARAMETER needs to be marked in BLOCK
  2015-10-26 19:58 [PATCH] PR fortran/67885 -- PARAMETER needs to be marked in BLOCK Steve Kargl
@ 2015-10-27  7:15 ` Thomas Koenig
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Koenig @ 2015-10-27  7:15 UTC (permalink / raw)
  To: Steve Kargl, fortran, gcc-patches

Hi Steve,

> When an specification statement in a BLOCK construct has a
> PARAMETER attribute, gfortran currently discards the entity.
> This patch marks PARAMETER entity if in a BLOCK.  I'm not
> complete convince that this is the right fix, but it does
> allow the testcase to compile and run.  Built and tested
> on x86_64-*-freebsd.  OK to commit (if not no one has a
> better patch)?

OK.  And thanks for the patch!

	Thomas

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

end of thread, other threads:[~2015-10-27  6:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-26 19:58 [PATCH] PR fortran/67885 -- PARAMETER needs to be marked in BLOCK Steve Kargl
2015-10-27  7:15 ` Thomas Koenig

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).