From: Steven G. Kargl Date: Sat, 30 Jul 2016 20:05:10 +0000 (+0000) Subject: re PR fortran/69867 (ICE on initializing character in type with array of incompatible... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e4f7a5dffe280edf9dcc57f50005fac5f71fcccb;p=gcc.git re PR fortran/69867 (ICE on initializing character in type with array of incompatible data) 2016-07-30 Steven G. Kargl PR fortran/69867 * decl.c (build_struct): Ensure that pointers point to something. 2016-07-30 Steven G. Kargl PR fortran/69867 * gfortran.dg/pr69867.f90: New test. From-SVN: r238907 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 5e8e7d1b820..13f1a9089db 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2016-07-30 Steven G. Kargl + + PR fortran/69867 + * decl.c (build_struct): Ensure that pointers point to something. + 2016-07-30 Steven G. Kargl PR fortran/69962 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index ae68c09f586..818e7d4ca98 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -1926,8 +1926,10 @@ build_struct (const char *name, gfc_charlen *cl, gfc_expr **init, if (c->initializer->expr_type == EXPR_CONSTANT) gfc_set_constant_character_len (len, c->initializer, -1); - else if (mpz_cmp (c->ts.u.cl->length->value.integer, - c->initializer->ts.u.cl->length->value.integer)) + else if (c->initializer + && c->initializer->ts.u.cl + && mpz_cmp (c->ts.u.cl->length->value.integer, + c->initializer->ts.u.cl->length->value.integer)) { gfc_constructor *ctor; ctor = gfc_constructor_first (c->initializer->value.constructor); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 73e2258fa29..8625717c5bf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-07-30 Steven G. Kargl + + PR fortran/69867 + * gfortran.dg/pr69867.f90: New test. + 2016-07-30 Steven G. Kargl PR fortran/69962 diff --git a/gcc/testsuite/gfortran.dg/pr69867.f90 b/gcc/testsuite/gfortran.dg/pr69867.f90 new file mode 100644 index 00000000000..132d5e83b16 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr69867.f90 @@ -0,0 +1,6 @@ +! { dg-do compile } +program p + type t + character(1) :: c(1)=[1] ! { dg-error "convert INTEGER.4. to CHARACTER.1." } + end type +end