is non-null when diagnosing a broken attempt to write a for-range-statement.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151081
91177308-0d34-0410-b5e6-
96231b3b80d8
return StmtError();
}
Collection = ParseExpression();
- } else if (getLang().CPlusPlus0x && Tok.is(tok::colon) &&
- !FirstPart.isInvalid()) {
+ } else if (getLang().CPlusPlus0x && Tok.is(tok::colon) && FirstPart.get()) {
// User tried to write the reasonable, but ill-formed, for-range-statement
// for (expr : expr) { ... }
Diag(Tok, diag::err_for_range_expected_decl)
template<typename T> void f() { for (auto a : A()) {} }
void g() { f<int>(); }
}
+
+namespace test4 {
+ void f() {
+ int y;
+
+ // Make sure these don't crash. Better diagnostics would be nice.
+ for (: {1, 2, 3}) {} // expected-error {{expected expression}} expected-error {{expected ';'}}
+ for (x : {1, 2, 3}) {} // expected-error {{undeclared identifier}} expected-error {{expected ';'}}
+ for (y : {1, 2, 3}) {} // expected-error {{must declare a variable}} expected-warning {{result unused}}
+ }
+}