Patchwork [gccgo] Better error message for missing statement after label

login
register
mail settings
Submitter Ian Taylor
Date Sept. 1, 2010, 4:35 a.m.
Message ID <mcrlj7maxns.fsf@google.com>
Download mbox | patch
Permalink /patch/63348/
State New
Headers show

Comments

Ian Taylor - Sept. 1, 2010, 4:35 a.m.
This patch improves gccgo's error message and subsequent processing when
a statement is missing after a label.  Committed to gccgo branch.

Ian

Patch

diff -r 5052eefabc12 go/parse.cc
--- a/go/parse.cc	Tue Aug 31 20:07:09 2010 -0700
+++ b/go/parse.cc	Tue Aug 31 21:34:26 2010 -0700
@@ -3072,6 +3072,14 @@ 
       return;
     }
 
+  if (!this->statement_may_start_here())
+    {
+      error_at(location, "missing statement after label");
+      this->unget_token(Token::make_operator_token(OPERATOR_SEMICOLON,
+						   location));
+      return;
+    }
+
   this->statement(label);
 }