diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2007-02-23 16:35:25 +0000 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2007-02-23 17:35:25 +0100 |
commit | 74a5d8b9fe448b0b12402e99de63948e10be7382 (patch) | |
tree | fceb6d1d9d0b1d44e068a31c3230419fe5ff643f /gcc/fortran/resolve.c | |
parent | 0a8f8c4572b2f0cea7f56922122275d2ff76746c (diff) | |
download | gcc-74a5d8b9fe448b0b12402e99de63948e10be7382.zip gcc-74a5d8b9fe448b0b12402e99de63948e10be7382.tar.gz gcc-74a5d8b9fe448b0b12402e99de63948e10be7382.tar.bz2 |
re PR fortran/30660 (Allocatable components of a derived type "require" the SAVE attribute.)
2007-02-23 Paul Thomas <pault@gcc.gnu.org>
PR fortran/30660
* resolve.c (has_default_initializer): New function.
(resolve_fl_variable): Call has_default_initializer to determine if
the derived type has a default initializer to its ultimate
components.
2007-02-23 Paul Thomas <pault@gcc.gnu.org>
PR fortran/30660
* gfortran.dg/alloc_comp_basics_4.f90: Add component with an
allocatable component.
From-SVN: r122263
Diffstat (limited to 'gcc/fortran/resolve.c')
-rw-r--r-- | gcc/fortran/resolve.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 8db36b5..a66d1ae 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -5529,6 +5529,21 @@ resolve_fl_var_and_proc (gfc_symbol *sym, int mp_flag) } +static gfc_component * +has_default_initializer (gfc_symbol *der) +{ + gfc_component *c; + for (c = der->components; c; c = c->next) + if ((c->ts.type != BT_DERIVED && c->initializer) + || (c->ts.type == BT_DERIVED + && !c->pointer + && has_default_initializer (c->ts.derived))) + break; + + return c; +} + + /* Resolve symbols with flavor variable. */ static try @@ -5676,9 +5691,7 @@ resolve_fl_variable (gfc_symbol *sym, int mp_flag) components. */ 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; + c = has_default_initializer (sym->ts.derived); /* 4th constraint in section 11.3: "If an object of a type for which component-initialization is specified (R429) appears in the |