diff options
author | Chris Lattner <sabre@nondot.org> | 2009-12-10 00:38:54 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-12-10 00:38:54 +0000 |
commit | 125c0ee5c7769c3db19838ac7184bb705d746aef (patch) | |
tree | bf1dc7cc7a57621783c4fca0fa2c42c6d92b50ed /clang/lib/Parse/ParseStmt.cpp | |
parent | 793c75a28f4a0ae9d62215b8ff853bd4749033c0 (diff) | |
download | bcm5719-llvm-125c0ee5c7769c3db19838ac7184bb705d746aef.tar.gz bcm5719-llvm-125c0ee5c7769c3db19838ac7184bb705d746aef.zip |
fix PR5740: a colon is sacred when parsing case statement expressions!
llvm-svn: 91016
Diffstat (limited to 'clang/lib/Parse/ParseStmt.cpp')
-rw-r--r-- | clang/lib/Parse/ParseStmt.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index f0de3f53456..5267ef0eccc 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -279,6 +279,11 @@ Parser::OwningStmtResult Parser::ParseCaseStatement(AttributeList *Attr) { ConsumeToken(); } + /// We don't want to treat 'case x : y' as a potential typo for 'case x::y'. + /// Disable this form of error recovery while we're parsing the case + /// expression. + ColonProtectionRAIIObject ColonProtection(*this); + OwningExprResult LHS(ParseConstantExpression()); if (LHS.isInvalid()) { SkipUntil(tok::colon); @@ -298,6 +303,8 @@ Parser::OwningStmtResult Parser::ParseCaseStatement(AttributeList *Attr) { return StmtError(); } } + + ColonProtection.restore(); if (Tok.isNot(tok::colon)) { Diag(Tok, diag::err_expected_colon_after) << "'case'"; |