From: Dominique d'Humieres Date: Fri, 14 Apr 2017 13:00:02 +0000 (+0200) Subject: backport: re PR fortran/59910 (ICE in gfc_conv_array_initializer, at fortran/trans... X-Git-Tag: releases/gcc-5.5.0~405 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29f0af6edd40f241e5fc0ba985c0b45194b198fd;p=thirdparty%2Fgcc.git backport: re PR fortran/59910 (ICE in gfc_conv_array_initializer, at fortran/trans-array.c:5327) 2017-04-14 Dominique d'Humieres Backport from trunk 2015-11-18 Steven G. Kargl PR fortran/59910 PR fortran/80388 * primary.c (gfc_match_structure_constructor): Reduce a structure constructor in a DATA statement. * gfortran.dg/pr59910.f90: New test. From-SVN: r246929 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9dc753b567c4..30c90d3f6031 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,13 @@ +2017-04-14 Dominique d'Humieres + + Backport from trunk + 2015-11-18 Steven G. Kargl + + PR fortran/59910 + PR fortran/80388 + * primary.c (gfc_match_structure_constructor): Reduce a structure + constructor in a DATA statement. + 2017-02-07 Steven G. Kargl * trans-types.c (gfc_get_int_kind_from_width_isofortranen): Choose diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c index 44b9901cf676..d2fe8bc0eac0 100644 --- a/gcc/fortran/primary.c +++ b/gcc/fortran/primary.c @@ -2657,6 +2657,12 @@ gfc_match_structure_constructor (gfc_symbol *sym, gfc_expr **result) return MATCH_ERROR; } + /* If a structure constructor is in a DATA statement, then each entity + in the structure constructor must be a constant. Try to reduce the + expression here. */ + if (gfc_in_match_data ()) + gfc_reduce_init_expr (e); + *result = e; return MATCH_YES; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d65d1ab7c368..1493a615d01b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2017-04-14 Dominique d'Humieres + + Backport from trunk + 2015-11-18 Steven G. Kargl + + PR fortran/59910 + PR fortran/80388 + * gfortran.dg/pr59910.f90: New test. + 2017-04-11 Thomas Preud'homme Backport from GCC 6 diff --git a/gcc/testsuite/gfortran.dg/pr59910.f90 b/gcc/testsuite/gfortran.dg/pr59910.f90 new file mode 100644 index 000000000000..2b288e4ff6c3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr59910.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! PR fortran/59910 +! +program main + implicit none + type bar + integer :: limit(1) + end type + type (bar) :: testsuite + data testsuite / bar(reshape(source=[10],shape=[1])) / +end