aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2020-10-29 21:55:16 +0100
committerThomas Koenig <tkoenig@gcc.gnu.org>2020-10-29 21:55:16 +0100
commit23856d2f29fd87edf724ade48ee30c869a3b1ea3 (patch)
tree2120b803f76a22fee0574a3a54a0f5a0809b20ba
parentb754f8cd7b1ccdc9a8d24f8e70da71c6e64996eb (diff)
downloadgcc-23856d2f29fd87edf724ade48ee30c869a3b1ea3.zip
gcc-23856d2f29fd87edf724ade48ee30c869a3b1ea3.tar.gz
gcc-23856d2f29fd87edf724ade48ee30c869a3b1ea3.tar.bz2
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.
-rw-r--r--gcc/fortran/trans-stmt.c6
-rw-r--r--gcc/fortran/trans-types.c3
2 files changed, 6 insertions, 3 deletions
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
index f4c3ed6..b2bd8e6 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 6b8589d74..aec027f 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)