Don't crash on erroneous type switch.
authorIan Lance Taylor <ian@gcc.gnu.org>
Tue, 22 Feb 2011 03:01:29 +0000 (03:01 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Tue, 22 Feb 2011 03:01:29 +0000 (03:01 +0000)
From-SVN: r170386

gcc/go/gofrontend/parse.cc

index fc8771c639cb22bb6acbfb9b636d166876cd8648..abd75fb27a6d9db84642cb2752933302a7f86a68 100644 (file)
@@ -3799,11 +3799,14 @@ Parse::switch_stat(const Label* label)
                  // This must be a TypeSwitchGuard.
                  switch_val = this->simple_stat(false, true, NULL,
                                                 &type_switch);
-                 if (!type_switch.found
-                     && !switch_val->is_error_expression())
+                 if (!type_switch.found)
                    {
-                     error_at(id_loc, "expected type switch assignment");
-                     switch_val = Expression::make_error(id_loc);
+                     if (switch_val == NULL
+                         || !switch_val->is_error_expression())
+                       {
+                         error_at(id_loc, "expected type switch assignment");
+                         switch_val = Expression::make_error(id_loc);
+                       }
                    }
                }
            }