Don't crash on erroneous type switch.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 22 Feb 2011 03:01:29 +0000 (03:01 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 22 Feb 2011 03:01:29 +0000 (03:01 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170386 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/go/gofrontend/parse.cc

index fc8771c..abd75fb 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);
+                       }
                    }
                }
            }