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);
return StmtError();
}
}
+
+ ColonProtection.restore();
if (Tok.isNot(tok::colon)) {
Diag(Tok, diag::err_expected_colon_after) << "'case'";
P.ColonIsSacred = true;
}
- ~ColonProtectionRAIIObject() {
+ /// restore - This can be used to restore the state early, before the dtor
+ /// is run.
+ void restore() {
P.ColonIsSacred = OldVal;
}
+
+ ~ColonProtectionRAIIObject() {
+ restore();
+ }
};
} // end namespace clang
// RUN: clang-cc -fsyntax-only -verify %s
-void f()
+void f1()
{
try {
;
}
}
-void g()
+void f2()
{
try; // expected-error {{expected '{'}}
catch {} // expected-error {{expected '('}}
}
-void h() try {
+void f3() try {
} catch(...) {
}
A::A(char) : i(0) try {} // expected-error {{expected '{' or ','}}
A::A(int j) try : i(j) {} catch(...) {}
+
+
+
+// PR5740
+struct Type { };
+
+enum { Type } Kind;
+void f4() {
+ int i = 0;
+ switch (Kind) {
+ case Type: i = 7; break; // no error.
+ }
+}
\ No newline at end of file