public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pault at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/30660] Allocatable components of a derived type "require" the SAVE attribute.
Date: Fri, 02 Feb 2007 16:15:00 -0000	[thread overview]
Message-ID: <20070202161526.15013.qmail@sourceware.org> (raw)
In-Reply-To: <bug-30660-109@http.gcc.gnu.org/bugzilla/>



------- Comment #3 from pault at gcc dot gnu dot org  2007-02-02 16:15 -------
This does the right thing and does not break anything.  However, it is still
not quite the definitive fix - it is not right for derived type components and
gfc_default_initializer now does not look right. I'll need a few days on this
one.

Paul

Index: gcc/fortran/resolve.c
===================================================================
*** gcc/fortran/resolve.c       (revision 121497)
--- gcc/fortran/resolve.c       (working copy)
*************** resolve_fl_variable (gfc_symbol *sym, in
*** 5534,5540 ****
    int flag;
    int i;
    gfc_expr *e;
!   gfc_expr *constructor_expr;
    const char *auto_save_msg;

    auto_save_msg = "automatic object '%s' at %L cannot have the "
--- 5534,5540 ----
    int flag;
    int i;
    gfc_expr *e;
!   gfc_component *c;
    const char *auto_save_msg;

    auto_save_msg = "automatic object '%s' at %L cannot have the "
*************** resolve_fl_variable (gfc_symbol *sym, in
*** 5668,5685 ****
        }
      }

    /* 4th constraint in section 11.3:  "If an object of a type for which
       component-initialization is specified (R429) appears in the
       specification-part of a module and does not have the ALLOCATABLE
       or POINTER attribute, the object shall have the SAVE attribute."  */

!   constructor_expr = NULL;
!   if (sym->ts.type == BT_DERIVED && !(sym->value || flag))
!     constructor_expr = gfc_default_initializer (&sym->ts);
! 
!   if (sym->ns->proc_name
        && sym->ns->proc_name->attr.flavor == FL_MODULE
-       && constructor_expr
        && !sym->ns->save_all && !sym->attr.save
        && !sym->attr.pointer && !sym->attr.allocatable)
      {
--- 5668,5689 ----
        }
      }

+   /* Do not use gfc_default_initializer to test for a default initializer
+      in the fortran because it generates a hidden default for allocatable
+      components.  TODO - clean this up. */
+   c = NULL;
+   if (sym->ts.type == BT_DERIVED && !(sym->value || flag))
+     for (c = sym->ts.derived->components; c; c = c->next)
+       if (c->initializer)
+       break;
+ 
    /* 4th constraint in section 11.3:  "If an object of a type for which
       component-initialization is specified (R429) appears in the
       specification-part of a module and does not have the ALLOCATABLE
       or POINTER attribute, the object shall have the SAVE attribute."  */

!   if (c && sym->ns->proc_name
        && sym->ns->proc_name->attr.flavor == FL_MODULE
        && !sym->ns->save_all && !sym->attr.save
        && !sym->attr.pointer && !sym->attr.allocatable)
      {


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pault at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2007-02-02 13:14:05         |2007-02-02 16:15:26
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30660


  parent reply	other threads:[~2007-02-02 16:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-31 21:34 [Bug fortran/30660] New: " toon at moene dot indiv dot nluug dot nl
2007-01-31 21:38 ` [Bug fortran/30660] " toon at moene dot indiv dot nluug dot nl
2007-02-02 13:14 ` pault at gcc dot gnu dot org
2007-02-02 16:15 ` pault at gcc dot gnu dot org [this message]
2007-02-03 12:46 ` fxcoudert at gcc dot gnu dot org
2007-02-03 13:39 ` pault at gcc dot gnu dot org
2007-02-04 13:17 ` [Bug fortran/30660] [4.2 and 4.1 only] " toon at moene dot indiv dot nluug dot nl
2007-02-05  9:37 ` paulthomas2 at wanadoo dot fr
2007-02-11  9:57 ` pault at gcc dot gnu dot org
2007-02-17 22:42 ` pault at gcc dot gnu dot org
2007-02-19 21:02 ` mmitchel at gcc dot gnu dot org
2007-02-22 22:10 ` patchapp at dberlin dot org
2007-02-23 16:35 ` burnus at gcc dot gnu dot org
2007-03-01  9:44 ` [Bug fortran/30660] [4.2 " burnus at gcc dot gnu dot org
2007-03-01  9:45 ` [Bug fortran/30660] " burnus at gcc dot gnu dot org

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=20070202161526.15013.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).