public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tobias Burnus <burnus@net-b.de>
To: gfortran g <fortran@gcc.gnu.org>,  gcc patches <gcc-patches@gcc.gnu.org>
Subject: [Patch,Fortran] PR 45756 Fix muliple-decl issue with PARAMETER
Date: Tue, 28 Sep 2010 15:52:00 -0000	[thread overview]
Message-ID: <4CA1E78C.1010802@net-b.de> (raw)

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

  For PARAMETERs in MODULEs which are of derived type or array-valued 
gfortran creates a static variable. This patch ensures that no extra 
declaration is generated for use associated parameters.

If one runs the testcase (see PR) without patch, the result of 
-fdump-tree-original-uid is:

   iD.1554 = paraD.1556[0];
   jD.1559 = paraD.1561[0];

with the patch, the result is:
   iD.1513 = paraD.1510[0];
   jD.1516 = paraD.1510[0];


Build on x86-64-linux and currently regtesting; if it succeeds:
OK for the trunk?

Tobias


[-- Attachment #2: gsym-parameter.diff --]
[-- Type: text/x-patch, Size: 1629 bytes --]

2010-09-28  Tobias Burnus  <burnus@net-b.de>

	PR fortran/45756
	* trans-decl.c (gfc_get_symbol_decl): Use gsym for decl of
	module parameters.

Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c	(revision 164682)
+++ gcc/fortran/trans-decl.c	(working copy)
@@ -1133,11 +1133,18 @@ gfc_get_symbol_decl (gfc_symbol * sym)
   if (sym->backend_decl)
     return sym->backend_decl;
 
+  /* Special case for array-valued named constants from intrinsic
+     procedures; those are inlined.  */
+  if (sym->attr.use_assoc && sym->from_intmod
+      && sym->attr.flavor == FL_PARAMETER)
+    intrinsic_array_parameter = true;
+
   /* If use associated and whole file compilation, use the module
      declaration.  */
   if (gfc_option.flag_whole_file
-	&& sym->attr.flavor == FL_VARIABLE
-	&& sym->attr.use_assoc
+	&& (sym->attr.flavor == FL_VARIABLE
+	    || sym->attr.flavor == FL_PARAMETER)
+	&& sym->attr.use_assoc && !intrinsic_array_parameter
 	&& sym->module)
     {
       gfc_gsymbol *gsym;
@@ -1182,12 +1189,6 @@ gfc_get_symbol_decl (gfc_symbol * sym)
   if (sym->attr.intrinsic)
     internal_error ("intrinsic variable which isn't a procedure");
 
-  /* Special case for array-valued named constants from intrinsic
-     procedures; those are inlined.  */
-  if (sym->attr.use_assoc && sym->from_intmod && sym->attr.dimension
-      && sym->attr.flavor == FL_PARAMETER)
-    intrinsic_array_parameter = true;
-
   /* Create string length decl first so that they can be used in the
      type declaration.  */
   if (sym->ts.type == BT_CHARACTER)

             reply	other threads:[~2010-09-28 13:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-28 15:52 Tobias Burnus [this message]
2010-09-28 16:30 ` Jerry DeLisle
2010-09-28 16:49   ` Paul Richard Thomas
2010-09-28 16:56     ` Tobias Burnus
2010-09-28 17:11       ` Paul Richard Thomas
2010-09-28 18:24         ` Tobias Burnus
2010-09-28 18:53           ` Paul Richard Thomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4CA1E78C.1010802@net-b.de \
    --to=burnus@net-b.de \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).