From eca18fb4b61a16634e61b7cf281ab65ef3292a74 Mon Sep 17 00:00:00 2001 From: Andrew Pinski Date: Wed, 2 Nov 2005 21:01:54 +0000 Subject: [PATCH] re PR fortran/18157 (ice-on-valid code, pointer to user-defined type, fold-struct.c) 2005-11-02 Andrew Pinski PR fortran/18157 * gfortran.fortran-torture/compile/defined_type_1.f90: New test. * gfortran.fortran-torture/compile/defined_type_2.f90: New test. * gfortran.fortran-torture/compile/defined_type_3.f90: New test. 2005-11-02 Andrew Pinski PR fortran/18157 * trans-array.c (gfc_conv_resolve_dependencies): Use the correct type for the temporary array. * trans-expr.c (gfc_trans_assignment): Pass lss instead of lss_section to gfc_conv_resolve_dependencies to get the correct type. From-SVN: r106396 --- gcc/fortran/ChangeLog | 10 ++++++++++ gcc/fortran/trans-array.c | 7 +++++-- gcc/fortran/trans-expr.c | 2 +- gcc/testsuite/ChangeLog | 9 +++++++++ .../compile/defined_type_1.f90 | 10 ++++++++++ .../compile/defined_type_2.f90 | 17 +++++++++++++++++ .../compile/defined_type_3.f90 | 10 ++++++++++ 7 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.fortran-torture/compile/defined_type_1.f90 create mode 100644 gcc/testsuite/gfortran.fortran-torture/compile/defined_type_2.f90 create mode 100644 gcc/testsuite/gfortran.fortran-torture/compile/defined_type_3.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index de6fed33320..8589e1c30bc 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,13 @@ +2005-11-02 Andrew Pinski + + PR fortran/18157 + * trans-array.c (gfc_conv_resolve_dependencies): Use the correct + type for the temporary array. + * trans-expr.c (gfc_trans_assignment): Pass lss + instead of lss_section + to gfc_conv_resolve_dependencies to get the + correct type. + 2005-11-02 Tobias Schl"uter * decl.c (gfc_match_entry): Function entries don't need an argument diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 72669f8ac3f..20d3c67a0bb 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -2542,10 +2542,13 @@ gfc_conv_resolve_dependencies (gfc_loopinfo * loop, gfc_ss * dest, if (nDepend == 1) { + tree base_type = gfc_typenode_for_spec (&dest->expr->ts); + if (GFC_ARRAY_TYPE_P (base_type) + || GFC_DESCRIPTOR_TYPE_P (base_type)) + base_type = gfc_get_element_type (base_type); loop->temp_ss = gfc_get_ss (); loop->temp_ss->type = GFC_SS_TEMP; - loop->temp_ss->data.temp.type = - gfc_get_element_type (TREE_TYPE (dest->data.info.descriptor)); + loop->temp_ss->data.temp.type = base_type; loop->temp_ss->string_length = dest->string_length; loop->temp_ss->data.temp.dimen = loop->dimen; loop->temp_ss->next = gfc_ss_terminator; diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index f911487030b..a0339af96c4 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -2719,7 +2719,7 @@ gfc_trans_assignment (gfc_expr * expr1, gfc_expr * expr2) /* Calculate the bounds of the scalarization. */ gfc_conv_ss_startstride (&loop); /* Resolve any data dependencies in the statement. */ - gfc_conv_resolve_dependencies (&loop, lss_section, rss); + gfc_conv_resolve_dependencies (&loop, lss, rss); /* Setup the scalarizing loops. */ gfc_conv_loop_setup (&loop); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 04a33426430..0b9bd9276fe 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2005-11-02 Andrew Pinski + + PR fortran/18157 + * gfortran.fortran-torture/compile/defined_type_1.f90: New test. + * gfortran.fortran-torture/compile/defined_type_2.f90: New + test. + * gfortran.fortran-torture/compile/defined_type_3.f90: + New test. + 2005-11-02 Mark Mitchell PR c++/24569 diff --git a/gcc/testsuite/gfortran.fortran-torture/compile/defined_type_1.f90 b/gcc/testsuite/gfortran.fortran-torture/compile/defined_type_1.f90 new file mode 100644 index 00000000000..635727b6630 --- /dev/null +++ b/gcc/testsuite/gfortran.fortran-torture/compile/defined_type_1.f90 @@ -0,0 +1,10 @@ +!This used to ICE as we chose the wrong type for the +! temporary to hold type%var +! fortran/18157 +program testcase_fold + type :: struct + real :: var ! its julian sec + end type struct + type(struct), dimension(:), pointer :: mystruct + mystruct(:)%var = mystruct(:)%var +END Program testcase_fold diff --git a/gcc/testsuite/gfortran.fortran-torture/compile/defined_type_2.f90 b/gcc/testsuite/gfortran.fortran-torture/compile/defined_type_2.f90 new file mode 100644 index 00000000000..29515f5561e --- /dev/null +++ b/gcc/testsuite/gfortran.fortran-torture/compile/defined_type_2.f90 @@ -0,0 +1,17 @@ +!This used to ICE as we chose the wrong type for the +! temporary to hold type%x +! fortran/18157 +MODULE bug + IMPLICIT NONE + TYPE :: my_type + REAL :: x + END TYPE + TYPE (my_type), DIMENSION(3) :: t + CONTAINS + SUBROUTINE foo + INTEGER, DIMENSION(8) :: c(3) + t(c)%x = t(c)%x + RETURN + END SUBROUTINE foo +END MODULE bug + diff --git a/gcc/testsuite/gfortran.fortran-torture/compile/defined_type_3.f90 b/gcc/testsuite/gfortran.fortran-torture/compile/defined_type_3.f90 new file mode 100644 index 00000000000..d31167cc497 --- /dev/null +++ b/gcc/testsuite/gfortran.fortran-torture/compile/defined_type_3.f90 @@ -0,0 +1,10 @@ +!This used to ICE as we chose the wrong type for the +! temporary to hold type%var +! fortran/18157 +program testcase_fold + type :: struct + real :: var ! its julian sec + end type struct + type(struct), dimension(:), pointer :: mystruct + mystruct(1:2)%var = mystruct(2:3)%var +END Program testcase_fold