From: burnus Date: Fri, 23 Feb 2007 16:35:25 +0000 (+0000) Subject: 2007-02-23 Paul Thomas X-Git-Tag: upstream/4.9.2~50209 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5365d8a296292be46689fc63dc311e4f9cb91724;p=platform%2Fupstream%2Flinaro-gcc.git 2007-02-23 Paul Thomas 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 PR fortran/30660 * gfortran.dg/alloc_comp_basics_4.f90: Add component with an allocatable component. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122263 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ce30553..777f926 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2007-02-23 Paul Thomas + + 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-22 Jerry DeLisle * options.c (set_default_std_flags): New function to consolidate 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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cce1dd9..45bed9f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2007-02-23 Paul Thomas + + PR fortran/30660 + * gfortran.dg/alloc_comp_basics_4.f90: Add component with an + allocatable component. + + 2007-02-23 Kaveh R. Ghazi * gcc.dg/torture/builtin-logb-1.c: New test. diff --git a/gcc/testsuite/gfortran.dg/alloc_comp_basics_4.f90 b/gcc/testsuite/gfortran.dg/alloc_comp_basics_4.f90 index c910b70..508d567 100644 --- a/gcc/testsuite/gfortran.dg/alloc_comp_basics_4.f90 +++ b/gcc/testsuite/gfortran.dg/alloc_comp_basics_4.f90 @@ -6,8 +6,14 @@ ! Contributed by Toon Moene ! MODULE types_m + TYPE coord_t + INTEGER ncord + REAL,ALLOCATABLE,DIMENSION(:) :: x, y + END TYPE + TYPE grib_t REAL,DIMENSION(:),ALLOCATABLE :: vdata + TYPE(coord_t) coords END TYPE END MODULE