From e34b2c298ae2fa7cb559364f70c78f0e6cc840c4 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 22 Jul 2007 04:13:33 +0000 Subject: [PATCH] Catch goto's with a missing identifier, patch by Neil Booth. llvm-svn: 40381 --- clang/Parse/ParseStmt.cpp | 4 ++++ clang/test/Parser/goto-ident.c | 6 ++++++ 2 files changed, 10 insertions(+) create mode 100644 clang/test/Parser/goto-ident.c diff --git a/clang/Parse/ParseStmt.cpp b/clang/Parse/ParseStmt.cpp index 27c1fa88a13c..564b09722f20 100644 --- a/clang/Parse/ParseStmt.cpp +++ b/clang/Parse/ParseStmt.cpp @@ -680,7 +680,11 @@ Parser::StmtResult Parser::ParseGotoStatement() { return true; } Res = Actions.ParseIndirectGotoStmt(GotoLoc, StarLoc, R.Val); + } else { + Diag(Tok, diag::err_expected_ident); + return true; } + return Res; } diff --git a/clang/test/Parser/goto-ident.c b/clang/test/Parser/goto-ident.c new file mode 100644 index 000000000000..0dc7f4ec40db --- /dev/null +++ b/clang/test/Parser/goto-ident.c @@ -0,0 +1,6 @@ +/* RUN: clang -parse-ast-check %s +*/ + +void foo() { + goto ; /* expected-error {{expected identifier}} */ +}