From: Thomas Koenig Date: Thu, 29 Oct 2020 20:55:16 +0000 (+0100) Subject: Fix two cases where -fcoarray=shared broke non-coarrays programs. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=23856d2f29fd87edf724ade48ee30c869a3b1ea3;p=thirdparty%2Fgcc.git Fix two cases where -fcoarray=shared broke non-coarrays programs. 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. --- diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index f4c3ed6de728..b2bd8e6e9b72 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -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); diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index 6b8589d7474c..aec027f1ffba 100644 --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -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)