public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, committed] Fix PR fortran/80752
@ 2017-05-15 19:38 Steve Kargl
  0 siblings, 0 replies; only message in thread
From: Steve Kargl @ 2017-05-15 19:38 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 425 bytes --]

I've committed the attached patch.

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.

-- 
Steve
20170425 https://www.youtube.com/watch?v=VWUpyCsUKR4
20161221 https://www.youtube.com/watch?v=IbCHE-hONow

[-- Attachment #2: pr80752.diff --]
[-- Type: text/x-diff, Size: 1259 bytes --]

Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c	(revision 248066)
+++ gcc/fortran/expr.c	(working copy)
@@ -4395,7 +4395,12 @@ gfc_generate_initializer (gfc_typespec *
 	  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: gcc/testsuite/gfortran.dg/pr80752.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr80752.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr80752.f90	(working copy)
@@ -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
+

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-05-15 19:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-15 19:38 [PATCH, committed] Fix PR fortran/80752 Steve Kargl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).