diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2018-03-19 07:04:35 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2018-03-19 07:04:35 +0000 |
commit | 949d0060b422c03f809fcd17883470c20a15ff4a (patch) | |
tree | a4debf79b5621aeb0c3992b8a9adc66491b0d25e /gcc | |
parent | 43bb589d9b79360168c9a4583fb90299a2cf94d8 (diff) | |
download | gcc-949d0060b422c03f809fcd17883470c20a15ff4a.zip gcc-949d0060b422c03f809fcd17883470c20a15ff4a.tar.gz gcc-949d0060b422c03f809fcd17883470c20a15ff4a.tar.bz2 |
re PR fortran/84931 (Expansion of array constructor with constant implied-do-object goes sideways)
2018-03-19 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/84931
* simplify.c (gfc_convert_constant): Correctly handle iterators
for type conversion.
2018-03-19 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/84931
* gfortran.dg/array_constructor_52.f90: New test.
From-SVN: r258641
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/simplify.c | 30 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/array_constructor_52.f90 | 11 |
4 files changed, 40 insertions, 12 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 7b550aa..8db0754 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-03-19 Thomas Koenig <tkoenig@gcc.gnu.org> + + PR fortran/84931 + * simplify.c (gfc_convert_constant): Correctly handle iterators + for type conversion. + 2018-03-18 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/77414 diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index 680e625..44290ac 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -8016,26 +8016,32 @@ gfc_convert_constant (gfc_expr *e, bt type, int kind) { gfc_expr *tmp; if (c->iterator == NULL) - tmp = f (c->expr, kind); + { + tmp = f (c->expr, kind); + if (tmp == NULL) + { + gfc_free_expr (result); + return NULL; + } + + gfc_constructor_append_expr (&result->value.constructor, + tmp, &c->where); + } else { + gfc_constructor *n; g = gfc_convert_constant (c->expr, type, kind); - if (g == &gfc_bad_expr) + if (g == NULL || g == &gfc_bad_expr) { gfc_free_expr (result); return g; } - tmp = g; - } - - if (tmp == NULL) - { - gfc_free_expr (result); - return NULL; + n = gfc_constructor_get (); + n->expr = g; + n->iterator = gfc_copy_iterator (c->iterator); + n->where = c->where; + gfc_constructor_append (&result->value.constructor, n); } - - gfc_constructor_append_expr (&result->value.constructor, - tmp, &c->where); } break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a7b96dd..cdce63d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-19 Thomas Koenig <tkoenig@gcc.gnu.org> + + PR fortran/84931 + * gfortran.dg/array_constructor_52.f90: New test. + 2018-03-17 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/77414 diff --git a/gcc/testsuite/gfortran.dg/array_constructor_52.f90 b/gcc/testsuite/gfortran.dg/array_constructor_52.f90 new file mode 100644 index 0000000..63581ac --- /dev/null +++ b/gcc/testsuite/gfortran.dg/array_constructor_52.f90 @@ -0,0 +1,11 @@ +! { dg-do run } +! PR 84931 - long array constructors with type conversion were not +! handled correctly. +program test + implicit none + integer, parameter :: n = 2**16 + real, dimension(n) :: y + integer :: i + y = (/ (1, i=1, n) /) + if (y(2) /= 1) stop 1 +end program test |