diff mbox series

[fortran] Fix PR 79795

Message ID df044c46-43a2-444f-f5b2-2a9ffca093cf@netcologne.de
State New
Headers show
Series [fortran] Fix PR 79795 | expand

Commit Message

Thomas Koenig Oct. 15, 2017, 6:09 p.m. UTC
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  <tkoenig@gcc.gnu.org>

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

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

         PR fortran/79795
         * gfortran.dg/assumed_size_2.f90: New test.

Comments

Jerry DeLisle Oct. 18, 2017, 1:10 a.m. UTC | #1
On 10/15/2017 11:09 AM, Thomas Koenig wrote:
> 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)?
> 

Yes, OK, thanks.

Jerry
diff mbox series

Patch

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)