This fixes a failing assertion in gfc_build_array_ref. While array(x,:) still refers to an array, array(x,y) is a single element, and thus coarray(x,y) is a descriptor whose data component points to something that is not an array. gfc_conv_expr_descriptor, to update data pointer with subreferences, calls gfc_get_dataptr_offset which in turn calls gfc_build_array_ref, which expects an array. In the non-array case, as there is no extra offset corresponding to array element, there is nothing to do here. This patch returns early in that case.
OK? PS: I'm not very confident with the span stuff this function is about, so I wouldn't mind Paul having a look.
2011-10-06 Mikael Morin <mikael.mo...@sfr.fr> PR fortran/50420 * trans.c (gfc_build_array_ref): If type is not an array, check that there is nothing to do, and do nothing.
diff --git a/trans.c b/trans.c index 764bdf4..1deff32 100644 --- a/trans.c +++ b/trans.c @@ -323,7 +323,14 @@ gfc_build_array_ref (tree base, tree offset, tree decl) return fold_convert (TYPE_MAIN_VARIANT (type), base); } - gcc_assert (TREE_CODE (type) == ARRAY_TYPE); + /* Scalar coarray, there is nothing to do. */ + if (TREE_CODE (type) != ARRAY_TYPE) + { + gcc_assert (decl == NULL_TREE); + gcc_assert (integer_zerop (offset)); + return base; + } + type = TREE_TYPE (type); if (DECL_P (base))