re PR fortran/80752 (ICE with wrong type initialization)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Mon, 15 May 2017 19:34:52 +0000 (19:34 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Mon, 15 May 2017 19:34:52 +0000 (19:34 +0000)
2017-05-15  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/80752
* expr.c (gfc_generate_initializer):  If type conversion fails,
check for error and return NULL.

2017-05-15  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/80752
gfortran.dg/pr80752.f90: New test.

From-SVN: r248072

gcc/fortran/ChangeLog
gcc/fortran/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr80752.f90 [new file with mode: 0644]

index f962ca93f29f84b5eff7634fc35e67d78f3591df..07cbea03c92e5869d4a43624e544d4012987d99a 100644 (file)
@@ -1,3 +1,9 @@
+2017-05-15  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/80752
+       * expr.c (gfc_generate_initializer):  If type conversion fails,
+       check for error and return NULL.
+
 2017-05-14  Nicolas Koenig  <koenigni@student.ethz.ch>
 
        PR fortran/80442
index c8be9513af59c6bd3a0bd40280732230f9273829..c7d3e549c5b9edc0339865aa0262177e4bc2f262 100644 (file)
@@ -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
index 898656ae6d98586bf4cdf3cad723eb438bb36459..0082e857f37272ed79c7117b92d06a30f0168baf 100644 (file)
@@ -1,3 +1,8 @@
+2017-05-15  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/80752
+       gfortran.dg/pr80752.f90: New test.
+
 2017-05-15  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/80425
diff --git a/gcc/testsuite/gfortran.dg/pr80752.f90 b/gcc/testsuite/gfortran.dg/pr80752.f90
new file mode 100644 (file)
index 0000000..00a4b33
--- /dev/null
@@ -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
+