]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix two cases where -fcoarray=shared broke non-coarrays programs.
authorThomas Koenig <tkoenig@gcc.gnu.org>
Thu, 29 Oct 2020 20:55:16 +0000 (21:55 +0100)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Thu, 29 Oct 2020 20:55:16 +0000 (21:55 +0100)
gcc/fortran/ChangeLog:

* trans-stmt.c (gfc_trans_deallocate): Style fix. Allow for NULL
pointer in ref.
* trans-types.c (gfc_get_array_type_bounds): Explicit test for
codimen if shared coarrays are used.

gcc/fortran/trans-stmt.c
gcc/fortran/trans-types.c

index f4c3ed6de728ba45e36e7c6505dfc572cdef992d..b2bd8e6e9b72ddcc02ece13ad1d17e6f5ac9d1c7 100644 (file)
@@ -7332,9 +7332,11 @@ gfc_trans_deallocate (gfc_code *code)
         {
          gfc_ref *ref, *last;
 
-         for (ref = expr->ref, last = ref; ref; last = ref, ref = ref->next);
+         for (ref = expr->ref, last = ref; ref; last = ref, ref = ref->next)
+           ;
+
          ref = last;
-         if (ref->type == REF_ARRAY && ref->u.ar.codimen)
+         if (ref && ref->type == REF_ARRAY && ref->u.ar.codimen)
            {
              gfc_symbol *sym = expr->symtree->n.sym;
              int alloc_type = gfc_native_coarray_get_allocation_type (sym);
index 6b8589d7474c08a2dbc2d42ac99883279d2b129f..aec027f1ffba451d0c553e580fc2adf221e7dab6 100644 (file)
@@ -1993,7 +1993,8 @@ gfc_get_array_type_bounds (tree etype, int dimen, int codimen, tree * lbound,
   /* TODO: known offsets for descriptors.  */
   GFC_TYPE_ARRAY_OFFSET (fat_type) = NULL_TREE;
 
-  if (flag_coarray != GFC_FCOARRAY_SHARED && dimen == 0)
+  if ((flag_coarray != GFC_FCOARRAY_SHARED && dimen == 0)
+      || (flag_coarray == GFC_FCOARRAY_SHARED && dimen == 0 && codimen == 0))
     {
       arraytype =  build_pointer_type (etype);
       if (restricted)