From: Steven G. Kargl Date: Mon, 15 May 2017 19:34:52 +0000 (+0000) Subject: re PR fortran/80752 (ICE with wrong type initialization) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0735a1c8cf2fe23ade2f98e5dbaf1781f597471d;p=gcc.git re PR fortran/80752 (ICE with wrong type initialization) 2017-05-15 Steven G. Kargl PR fortran/80752 * expr.c (gfc_generate_initializer): If type conversion fails, check for error and return NULL. 2017-05-15 Steven G. Kargl PR fortran/80752 gfortran.dg/pr80752.f90: New test. From-SVN: r248072 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f962ca93f29..07cbea03c92 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2017-05-15 Steven G. Kargl + + PR fortran/80752 + * expr.c (gfc_generate_initializer): If type conversion fails, + check for error and return NULL. + 2017-05-14 Nicolas Koenig PR fortran/80442 diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index c8be9513af5..c7d3e549c5b 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -4395,7 +4395,12 @@ gfc_generate_initializer (gfc_typespec *ts, bool generate) if ((comp->ts.type != tmp->ts.type || comp->ts.kind != tmp->ts.kind) && !comp->attr.pointer && !comp->attr.proc_pointer) - gfc_convert_type_warn (ctor->expr, &comp->ts, 2, false); + { + bool val; + val = gfc_convert_type_warn (ctor->expr, &comp->ts, 1, false); + if (val == false) + return NULL; + } } if (comp->attr.allocatable diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 898656ae6d9..0082e857f37 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-05-15 Steven G. Kargl + + PR fortran/80752 + gfortran.dg/pr80752.f90: New test. + 2017-05-15 Uros Bizjak PR target/80425 diff --git a/gcc/testsuite/gfortran.dg/pr80752.f90 b/gcc/testsuite/gfortran.dg/pr80752.f90 new file mode 100644 index 00000000000..00a4b33d29a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr80752.f90 @@ -0,0 +1,20 @@ +! { dg-do compile } +! PR fortran/80752 +module exchange_utils + + implicit none + + integer, parameter, public :: knd = 8 + + type, private :: a + logical :: add_vs98 = 0.0_knd ! { dg-error "Can't convert" } + end type a + + type, private :: x_param_t + type(a) :: m05_m06 + end type x_param_t + + type(x_param_t), public, save :: x_param + +end module exchange_utils +