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]

[PATCH] PR fortran/77506


Regression tested on x86_64-*-freebsd.  OK to commit?

2016-09-08  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/77506
	* array.c (gfc_match_array_constructor): CHARACTER(len=*) cannot
	appear in an array constructor.

2016-09-08  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/77506
	* gfortran.dg/pr77506.f90: New test.

Index: gcc/fortran/array.c
===================================================================
--- gcc/fortran/array.c	(revision 240039)
+++ gcc/fortran/array.c	(working copy)
@@ -1142,6 +1142,15 @@ gfc_match_array_constructor (gfc_expr **
 	      gfc_restore_last_undo_checkpoint ();
 	      goto cleanup;
 	    }
+
+	  if (ts.type == BT_CHARACTER
+	      && ts.u.cl && !ts.u.cl->length && !ts.u.cl->length_from_typespec)
+	    {
+	      gfc_error ("Type-spec at %L cannot contain an asterisk for a "
+			 "type parameter", &where);
+	      gfc_restore_last_undo_checkpoint ();
+	      goto cleanup;
+	    }
 	}
     }
   else if (m == MATCH_ERROR)
Index: gcc/testsuite/gfortran.dg/pr77506.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr77506.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr77506.f90	(working copy)
@@ -0,0 +1,4 @@
+! { dg-do compile }
+program foo
+   print *, [character(len=*)::'ab','cd'] ! { dg-error "contain an asterisk" }
+end program foo

-- 
Steve


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