re PR fortran/18918 (Eventually support Fortran 2008's coarrays [co-arrays])
authorTobias Burnus <burnus@net-b.de>
Sat, 23 Apr 2011 10:26:38 +0000 (12:26 +0200)
committerTobias Burnus <burnus@gcc.gnu.org>
Sat, 23 Apr 2011 10:26:38 +0000 (12:26 +0200)
2011-04-23  Tobias Burnus  <burnus@net-b.de>

        PR fortran/18918
        * module.c (mio_array_spec): Set as->cotype on reading.
        * resolve.c (resolve_allocate_expr): Fix allocating coarray
        components.

2011-04-23  Tobias Burnus  <burnus@net-b.de>

        PR fortran/18918
        * gfortran.dg/coarray_19.f90: New.

From-SVN: r172897

gcc/fortran/ChangeLog
gcc/fortran/module.c
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/coarray_19.f90 [new file with mode: 0644]

index bbe8624a9ab51b869e52d99a72c6853a3e041f28..ec28bf4222da2e0e6b3fa0b2cf9434608b62f0d7 100644 (file)
@@ -1,3 +1,10 @@
+2011-04-23  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/18918
+       * module.c (mio_array_spec): Set as->cotype on reading.
+       * resolve.c (resolve_allocate_expr): Fix allocating coarray
+       components.
+
 2011-04-21  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/48405
index 42e8e00269259d267d32aebf99f590130747326b..fb8de0e39b6d74ee6f236769658a73d4664a0885 100644 (file)
@@ -2203,6 +2203,9 @@ mio_array_spec (gfc_array_spec **asp)
   mio_integer (&as->corank);
   as->type = MIO_NAME (array_type) (as->type, array_spec_types);
 
+  if (iomode == IO_INPUT && as->corank)
+    as->cotype = (as->type == AS_DEFERRED) ? AS_DEFERRED : AS_EXPLICIT;
+
   for (i = 0; i < as->rank + as->corank; i++)
     {
       mio_expr (&as->lower[i]);
index c10161213197da2a35af4f0a8aefc592005af9f5..d7b95f51e1775b2bc414229e2e5f767d1674cc0c 100644 (file)
@@ -6636,6 +6636,7 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code)
 {
   int i, pointer, allocatable, dimension, is_abstract;
   int codimension;
+  bool coindexed;
   symbol_attribute attr;
   gfc_ref *ref, *ref2;
   gfc_expr *e2;
@@ -6693,18 +6694,32 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code)
          codimension = sym->attr.codimension;
        }
 
+      coindexed = false;
+
       for (ref = e->ref; ref; ref2 = ref, ref = ref->next)
        {
          switch (ref->type)
            {
              case REF_ARRAY:
+                if (ref->u.ar.codimen > 0)
+                 {
+                   int n;
+                   for (n = ref->u.ar.dimen;
+                        n < ref->u.ar.dimen + ref->u.ar.codimen; n++)
+                     if (ref->u.ar.dimen_type[n] != DIMEN_THIS_IMAGE)
+                       {
+                         coindexed = true;
+                         break;
+                       }
+                  }
+
                if (ref->next != NULL)
                  pointer = 0;
                break;
 
              case REF_COMPONENT:
                /* F2008, C644.  */
-               if (gfc_is_coindexed (e))
+               if (coindexed)
                  {
                    gfc_error ("Coindexed allocatable object at %L",
                               &e->where);
index 08aa6d48241f9198345b38973224d1f10e1275bc..dfb9929fbb74a54db00e333529e2deadde0fcce3 100644 (file)
@@ -1,3 +1,8 @@
+2011-04-23  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/18918
+       * gfortran.dg/coarray_19.f90: New.
+
 2011-04-23  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/48685
diff --git a/gcc/testsuite/gfortran.dg/coarray_19.f90 b/gcc/testsuite/gfortran.dg/coarray_19.f90
new file mode 100644 (file)
index 0000000..cbb1dd2
--- /dev/null
@@ -0,0 +1,27 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=single" }
+!
+! PR fortran/18918
+!
+
+! Was failing before as the "x%a()[]" was
+! regarded as coindexed
+subroutine test2()
+  type t
+    integer, allocatable :: a(:)[:]
+  end type t
+  type(t), SAVE :: x
+  allocate(x%a(1)[*])
+end subroutine test2
+
+
+module m
+  integer, allocatable :: a(:)[:]
+end module m
+
+! Was failing as "a" was allocatable but
+! as->cotype was not AS_DEFERERED.
+use m
+end
+
+! { dg-final { cleanup-modules "m" } }