From 5912da3cd22ae3cdb32ae5631ad08072d039afbc Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Wed, 22 Apr 2015 22:43:46 +0000 Subject: [PATCH] re PR fortran/65429 (ICE on implied-length character empty array constructor) 2015-04-22 Steven G. Kargl PR fortran/65429 * decl.c (add_init_expr_to_sym): Set the length type parameter. PR fortran/65429 * gfortran.dg/pr65429.f90: New test. From-SVN: r222342 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/decl.c | 4 +--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr65429.f90 | 19 +++++++++++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr65429.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 4419b21c90d..2f85ecf3988 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2015-04-22 Steven G. Kargl + + PR fortran/65429 + * decl.c (add_init_expr_to_sym): Set the length type parameter. + 2015-04-10 Tobias Burnus * trans-stmt.c (gfc_trans_lock_unlock): Implement -fcoarray=lib diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 037a8cc47c3..0c15fb99036 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -1404,9 +1404,7 @@ add_init_expr_to_sym (const char *name, gfc_expr **initp, locus *var_locus) } else if (init->expr_type == EXPR_ARRAY) { - gfc_constructor *c; - c = gfc_constructor_first (init->value.constructor); - clen = c->expr->value.character.length; + clen = mpz_get_si (init->ts.u.cl->length->value.integer); sym->ts.u.cl->length = gfc_get_int_expr (gfc_default_integer_kind, NULL, clen); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 53667bc3c4a..7aff1743eab 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-04-22 Steven G. Kargl + + PR fortran/65429 + * gfortran.dg/pr65429.f90: New test. + 2015-04-22 Yury Gribov * c-c++-common/asan/user-section-1.c: New test. diff --git a/gcc/testsuite/gfortran.dg/pr65429.f90 b/gcc/testsuite/gfortran.dg/pr65429.f90 new file mode 100644 index 00000000000..505413c0b49 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr65429.f90 @@ -0,0 +1,19 @@ +! { dg-do run } +! PR fortran/65429 +program foo + + implicit none + + character(*), parameter :: s(*) = [ character(5) :: 'abcde', 'fghij' ] + character(*), parameter :: t(*) = [ character(31) :: ] + character(*), parameter :: u(*) = [ 'qwerty', 'asdfgh', 'zxcvbn'] + character(*), parameter :: v(*) = ['',''] + + if ((size(s) /= 2).or.(len(s)/=5)) call abort + if ((size(t) /= 0).or.(len(t)/=31)) call abort + if ((size(u) /= 3).or.(len(u)/=6)) call abort + if ((size(v) /= 2).or.(len(v)/=0)) call abort + if ((s(1)/='abcde').or.(s(2)/='fghij')) call abort + if ((u(1)/='qwerty').or.(u(2)/='asdfgh').or.(u(3)/='zxcvbn')) call abort + +end program foo -- 2.30.2