From 8a5c4899e8f57f09e288043984cc0f4584f17fc4 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Sun, 29 May 2011 20:15:08 +0200 Subject: [PATCH] re PR fortran/18918 (Eventually support Fortran 2008's coarrays [co-arrays]) 2011-05-29 Tobias Burnus Richard Guenther PR fortran/18918 * trans-types.c (gfc_get_nodesc_array_type): Don't mess with the type's TREE_TYPE. * trans-array.c (gfc_conv_array_ref): Use TYPE_MAIN_VARIANT. * trans.c (gfc_build_array_ref): Ditto. 2011-05-29 Tobias Burnus PR fortran/18918 * gfortran.dg/coarray_23.f90: New. Co-Authored-By: Richard Guenther From-SVN: r174410 --- gcc/fortran/ChangeLog | 9 +++++++++ gcc/fortran/trans-array.c | 2 +- gcc/fortran/trans-types.c | 5 +---- gcc/fortran/trans.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/coarray_23.f90 | 13 +++++++++++++ 6 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/coarray_23.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 10ec0b0a102..71e6452ca5b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2011-05-29 Tobias Burnus + Richard Guenther + + PR fortran/18918 + * trans-types.c (gfc_get_nodesc_array_type): Don't mess with + the type's TREE_TYPE. + * trans-array.c (gfc_conv_array_ref): Use TYPE_MAIN_VARIANT. + * trans.c (gfc_build_array_ref): Ditto. + 2011-05-27 Tobias Burnus PR fortran/18918 diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index b2992f0233d..d83a7a9d8ec 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -2628,7 +2628,7 @@ gfc_conv_array_ref (gfc_se * se, gfc_array_ref * ar, gfc_symbol * sym, se->expr = build_fold_indirect_ref_loc (input_location, se->expr); /* Use the actual tree type and not the wrapped coarray. */ - se->expr = fold_convert (TREE_TYPE (TREE_TYPE (se->expr)), se->expr); + se->expr = fold_convert (TYPE_MAIN_VARIANT (TREE_TYPE (se->expr)), se->expr); return; } diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index 94b9a591c10..02a75fd2819 100644 --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -1423,10 +1423,7 @@ gfc_get_nodesc_array_type (tree etype, gfc_array_spec * as, gfc_packed packed, if (as->rank) type = make_node (ARRAY_TYPE); else - { - type = build_variant_type_copy (etype); - TREE_TYPE (type) = etype; - } + type = build_variant_type_copy (etype); GFC_ARRAY_TYPE_P (type) = 1; TYPE_LANG_SPECIFIC (type) diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c index fcbb8505fd0..0ab4637851c 100644 --- a/gcc/fortran/trans.c +++ b/gcc/fortran/trans.c @@ -320,7 +320,7 @@ gfc_build_array_ref (tree base, tree offset, tree decl) { gcc_assert (GFC_TYPE_ARRAY_CORANK (type) > 0); - return fold_convert (TREE_TYPE (type), base); + return fold_convert (TYPE_MAIN_VARIANT (type), base); } gcc_assert (TREE_CODE (type) == ARRAY_TYPE); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index aa432830495..fce1c3256f7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-05-29 Tobias Burnus + + PR fortran/18918 + * gfortran.dg/coarray_23.f90: New. + 2011-05-29 Richard Sandiford From Ryan Mansfield diff --git a/gcc/testsuite/gfortran.dg/coarray_23.f90 b/gcc/testsuite/gfortran.dg/coarray_23.f90 new file mode 100644 index 00000000000..429928a4d86 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/coarray_23.f90 @@ -0,0 +1,13 @@ +! { dg-do compile } +! { dg-options "-fcoarray=single" } +! +! PR fortran/18918 +! +! The example was ICEing before as the tree-decl +! of the type was wrong. +! + + subroutine test + complex, save :: z[*] + if (z /= cmplx (0.0, 0.0)) call abort() + end subroutine test -- 2.30.2