OSDN Git Service

2011-02-18 Janus Weil <janus@gcc.gnu.org>
authorjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 18 Feb 2011 22:34:34 +0000 (22:34 +0000)
committerjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 18 Feb 2011 22:34:34 +0000 (22:34 +0000)
PR fortran/47789
* primary.c (gfc_match_structure_constructor): Handle empty parent
types.

2011-02-18  Janus Weil  <janus@gcc.gnu.org>

PR fortran/47789
* gfortran.dg/derived_constructor_comps_4.f90: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170291 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/primary.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/derived_constructor_comps_4.f90 [new file with mode: 0644]

index 2e9fc8c..d7dff6d 100644 (file)
@@ -1,3 +1,9 @@
+2011-02-18  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/47789
+       * primary.c (gfc_match_structure_constructor): Handle empty parent
+       types.
+
 2011-02-18  Tobias Burnus
 
        PR fortran/47775
index c8e2bb6..4cda7a1 100644 (file)
@@ -2310,6 +2310,12 @@ gfc_match_structure_constructor (gfc_symbol *sym, gfc_expr **result,
        {
          gfc_component *this_comp = NULL;
 
+         if (comp == sym->components && sym->attr.extension
+             && comp->ts.type == BT_DERIVED
+             && comp->ts.u.derived->attr.zero_comp)
+           /* Skip empty parents.  */ 
+           comp = comp->next;
+
          if (!comp_head)
            comp_tail = comp_head = gfc_get_structure_ctor_component ();
          else
index f023a37..54665c4 100644 (file)
@@ -1,3 +1,8 @@
+2011-02-18  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/47789
+       * gfortran.dg/derived_constructor_comps_4.f90: New.
+
 2011-02-18  Tobias Burnus
 
        PR fortran/47775
diff --git a/gcc/testsuite/gfortran.dg/derived_constructor_comps_4.f90 b/gcc/testsuite/gfortran.dg/derived_constructor_comps_4.f90
new file mode 100644 (file)
index 0000000..e705518
--- /dev/null
@@ -0,0 +1,18 @@
+! { dg-do run }
+!
+! PR 47789: [F03] Structure constructor of type extending DT with no components
+!
+! Contributed by eddyg_61-bugzilla@yahoo.it
+
+type:: one
+end type
+
+type, extends(one) :: two
+  integer :: a
+end type
+
+type(two) :: wo = two(6)
+
+if (wo%a /= 6) call abort()
+
+end