diff mbox series

[fortran] Fix PR 88008, ICE on invalid

Message ID 08a5c201-39cc-3bc7-2748-d628f5bfa5da@netcologne.de
State New
Headers show
Series [fortran] Fix PR 88008, ICE on invalid | expand

Commit Message

Thomas Koenig March 16, 2019, 3:05 p.m. UTC
Hello world,

this patch fixes an ICE on invalid 9 regression by converting
two asserts into gfc_error, plus fixups to the rest of the code.

Regression-tested. OK for trunk?

Regards

	Thomas
diff mbox series

Patch

Index: gfortran.h
===================================================================
--- gfortran.h	(Revision 269635)
+++ gfortran.h	(Arbeitskopie)
@@ -142,7 +142,7 @@  enum gfc_source_form
 
 /* Expression node types.  */
 enum expr_t
-{ EXPR_OP = 1, EXPR_FUNCTION, EXPR_CONSTANT, EXPR_VARIABLE,
+  { EXPR_UNKNOWN = 0, EXPR_OP = 1, EXPR_FUNCTION, EXPR_CONSTANT, EXPR_VARIABLE,
   EXPR_SUBSTRING, EXPR_STRUCTURE, EXPR_ARRAY, EXPR_NULL, EXPR_COMPCALL, EXPR_PPC
 };
 
Index: expr.c
===================================================================
--- expr.c	(Revision 269624)
+++ expr.c	(Arbeitskopie)
@@ -390,6 +390,9 @@  gfc_copy_expr (gfc_expr *p)
     case EXPR_VARIABLE:
     case EXPR_NULL:
       break;
+
+    case EXPR_UNKNOWN:
+      gcc_unreachable ();
     }
 
   q->shape = gfc_copy_shape (p->shape, p->rank);
@@ -2206,6 +2209,9 @@  gfc_simplify_expr (gfc_expr *p, int type)
     case EXPR_COMPCALL:
     case EXPR_PPC:
       break;
+
+    case EXPR_UNKNOWN:
+      gcc_unreachable ();
     }
 
   return true;
Index: module.c
===================================================================
--- module.c	(Revision 269624)
+++ module.c	(Arbeitskopie)
@@ -3694,6 +3694,7 @@  mio_expr (gfc_expr **ep)
 
     case EXPR_COMPCALL:
     case EXPR_PPC:
+    case EXPR_UNKNOWN:
       gcc_unreachable ();
       break;
     }
Index: resolve.c
===================================================================
--- resolve.c	(Revision 269635)
+++ resolve.c	(Arbeitskopie)
@@ -5945,6 +5945,13 @@  extract_compcall_passed_object (gfc_expr* e)
 {
   gfc_expr* po;
 
+  if (e->expr_type == EXPR_UNKNOWN)
+    {
+      gfc_error ("Error in component call at %L",
+		 &e->where);
+      return NULL;
+    }
+
   gcc_assert (e->expr_type == EXPR_COMPCALL);
 
   if (e->value.compcall.base_object)
@@ -6090,7 +6097,11 @@  check_typebound_baseobject (gfc_expr* e)
   if (!base)
     return false;
 
-  gcc_assert (base->ts.type == BT_DERIVED || base->ts.type == BT_CLASS);
+  if (base->ts.type != BT_DERIVED && base->ts.type != BT_CLASS)
+    {
+      gfc_error ("Error in component call at %L", &e->where);
+      goto cleanup;
+    }
 
   if (base->ts.type == BT_CLASS && !gfc_expr_attr (base).class_ok)
     return false;
Index: trans-expr.c
===================================================================
--- trans-expr.c	(Revision 269624)
+++ trans-expr.c	(Arbeitskopie)
@@ -4536,6 +4536,7 @@  gfc_apply_interface_mapping_to_expr (gfc_interface
 
     case EXPR_COMPCALL:
     case EXPR_PPC:
+    case EXPR_UNKNOWN:
       gcc_unreachable ();
       break;
     }