This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PR fortran/69867 -- Patch


Unless someone speaks up, I will commit the following
patch as obvious.

2016-07-29  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/69867
	* decl.c (build_struct): Ensure that pointers point to something.

2016-07-29  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/69867
	* gfortran.dg/pr69867.f90: New test.

Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c	(revision 238842)
+++ gcc/fortran/decl.c	(working copy)
@@ -1913,8 +1917,10 @@ build_struct (const char *name, gfc_char
 
       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);
Index: gcc/testsuite/gfortran.dg/pr69867.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr69867.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr69867.f90	(working copy)
@@ -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

-- 
Steve


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]