Hello world,

the attached patch fixes a regression by turning an ICE-on-invalid into
an error message (and making sure that it fits).

Regression-tested on trunk.

OK for all affected branches (8/7/6)?

Regards

        Thomas

2017-10-15  Thomas Koenig  <tkoe...@gcc.gnu.org>

        PR fortran/79795
        * resolve.c (resovle_symbol): Change gcc_assert to
        sensible error message.

2017-10-15  Thomas Koenig  <tkoe...@gcc.gnu.org>

        PR fortran/79795
        * gfortran.dg/assumed_size_2.f90: New test.
Index: resolve.c
===================================================================
--- resolve.c	(Revision 253768)
+++ resolve.c	(Arbeitskopie)
@@ -14403,7 +14403,23 @@ resolve_symbol (gfc_symbol *sym)
 
   if (as)
     {
-      gcc_assert (as->type != AS_IMPLIED_SHAPE);
+      /* If AS_IMPLIED_SHAPE makes it to here, it must be a bad
+	 specification expression.  */
+      if (as->type == AS_IMPLIED_SHAPE)
+	{
+	  int i;
+	  for (i=0; i<as->rank; i++)
+	    {
+	      if (as->lower[i] != NULL && as->upper[i] == NULL)
+		{
+		  gfc_error ("Bad specification for assumed size array at %L",
+			     &as->lower[i]->where);
+		  return;
+		}
+	    }
+	  gcc_unreachable();
+	}
+
       if (((as->type == AS_ASSUMED_SIZE && !as->cp_was_assumed)
 	   || as->type == AS_ASSUMED_SHAPE)
 	  && !sym->attr.dummy && !sym->attr.select_type_temporary)
! { dg-do compile }
subroutine foo(a)
  dimension  a(*,*) ! { dg-error "Bad specification for assumed size array" }
end

Reply via email to