trans-array.c (structure_alloc_comps): Fix for allocatable scalar coarray components.
authorTobias Burnus <burnus@net-b.de>
Thu, 25 Aug 2011 15:59:40 +0000 (17:59 +0200)
committerTobias Burnus <burnus@gcc.gnu.org>
Thu, 25 Aug 2011 15:59:40 +0000 (17:59 +0200)
2011-08-25  Tobias Burnus  <burnus@net-b.de>

        * trans-array.c (structure_alloc_comps): Fix for allocatable
        scalar coarray components.
        * trans-expr.c (gfc_conv_component_ref): Ditto.
        * trans-type.c (gfc_get_derived_type): Ditto.

2011-08-25  Tobias Burnus  <burnus@net-b.de>

        * gfortran.dg/coarray/alloc_comp_1.f90: New.

From-SVN: r178068

gcc/fortran/ChangeLog
gcc/fortran/trans-array.c
gcc/fortran/trans-expr.c
gcc/fortran/trans-types.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/coarray/alloc_comp_1.f90 [new file with mode: 0644]

index ed4dc77f020a99c8632e31ac9eff7bf66a274003..1c4a6737f1274fbfb1488e8fd9c0116abd5424bc 100644 (file)
@@ -1,3 +1,10 @@
+2011-08-25  Tobias Burnus  <burnus@net-b.de>
+
+       * trans-array.c (structure_alloc_comps): Fix for allocatable
+       scalar coarray components.
+       * trans-expr.c (gfc_conv_component_ref): Ditto.
+       * trans-type.c (gfc_get_derived_type): Ditto.
+
 2011-08-24  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/50163
index 3a756584933dc859c26547619d1d2649b6aff9c0..bd9e88efd3ac0be50246a743b311ed51b9f7ad77 100644 (file)
@@ -6798,7 +6798,8 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl,
              gfc_add_expr_to_block (&fnblock, tmp);
            }
 
-         if (c->attr.allocatable && c->attr.dimension)
+         if (c->attr.allocatable
+             && (c->attr.dimension || c->attr.codimension))
            {
              comp = fold_build3_loc (input_location, COMPONENT_REF, ctype,
                                      decl, cdecl, NULL_TREE);
@@ -6845,7 +6846,8 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl,
        case NULLIFY_ALLOC_COMP:
          if (c->attr.pointer)
            continue;
-         else if (c->attr.allocatable && c->attr.dimension)
+         else if (c->attr.allocatable
+                  && (c->attr.dimension|| c->attr.codimension))
            {
              comp = fold_build3_loc (input_location, COMPONENT_REF, ctype,
                                      decl, cdecl, NULL_TREE);
index 39a83ce4da3553d870d30e99f045bd4de5fb0aba..531a135c2f432de2afebd8df63cd5fef94a0a52a 100644 (file)
@@ -564,7 +564,8 @@ gfc_conv_component_ref (gfc_se * se, gfc_ref * ref)
       se->string_length = tmp;
     }
 
-  if (((c->attr.pointer || c->attr.allocatable) && c->attr.dimension == 0
+  if (((c->attr.pointer || c->attr.allocatable)
+       && (!c->attr.dimension && !c->attr.codimension)
        && c->ts.type != BT_CHARACTER)
       || c->attr.proc_pointer)
     se->expr = build_fold_indirect_ref_loc (input_location,
index bec2a116752bb144e86e501d0df8d981848f3d97..bac5b31e9c3d644b1254c5d22b2a636b56943ae0 100644 (file)
@@ -2395,7 +2395,7 @@ gfc_get_derived_type (gfc_symbol * derived)
 
       /* This returns an array descriptor type.  Initialization may be
          required.  */
-      if (c->attr.dimension && !c->attr.proc_pointer)
+      if ((c->attr.dimension || c->attr.codimension) && !c->attr.proc_pointer )
        {
          if (c->attr.pointer || c->attr.allocatable)
            {
index eda284a99fb8e6c679141af5609c9056036164d5..30b48b4e03dfc2f29d8b14cab6336435455148dc 100644 (file)
@@ -1,3 +1,7 @@
+2011-08-25  Tobias Burnus  <burnus@net-b.de>
+
+       * gfortran.dg/coarray/alloc_comp_1.f90: New.
+
 2011-08-25  Richard Guenther  <rguenther@suse.de>
 
        * gcc.dg/Wshadow-3.c: Restore original content destroyed by r148442.
diff --git a/gcc/testsuite/gfortran.dg/coarray/alloc_comp_1.f90 b/gcc/testsuite/gfortran.dg/coarray/alloc_comp_1.f90
new file mode 100644 (file)
index 0000000..6baeabf
--- /dev/null
@@ -0,0 +1,16 @@
+! { dg-do run }
+!
+! Allocatable scalar corrays were mishandled (ICE)
+!
+type t
+  integer, allocatable :: caf[:]
+end type t
+type(t) :: a
+allocate (a%caf[3:*])
+a%caf = 7
+!print *, a%caf
+if (a%caf /= 7) call abort ()
+if (any (lcobound (a%caf) /= [ 3 ]) &
+    .or. ucobound (a%caf, dim=1) /= this_image ()+2)  &
+  call abort ()
+end