fix PR5740: a colon is sacred when parsing case statement expressions!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91016 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index f0de3f5..5267ef0 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/lib/Parse/ParseStmt.cpp
@@ -279,6 +279,11 @@
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 @@
return StmtError();
}
}
+
+ ColonProtection.restore();
if (Tok.isNot(tok::colon)) {
Diag(Tok, diag::err_expected_colon_after) << "'case'";