OSDN Git Service

2011-04-23 Tobias Burnus <burnus@net-b.de>
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 23 Apr 2011 10:26:38 +0000 (10:26 +0000)
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 23 Apr 2011 10:26:38 +0000 (10:26 +0000)
        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.

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

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 bbe8624..ec28bf4 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 42e8e00..fb8de0e 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 c101612..d7b95f5 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 08aa6d4..dfb9929 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" } }