diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-12-20 22:56:20 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-12-20 22:56:20 +0000 |
commit | a44854a23b3f090729d82f447aa88df4f6563263 (patch) | |
tree | ff88ad4ea28f94605f93921aaede55f8721355f7 /lib/Parse/ParseStmt.cpp | |
parent | 2cbe791d3e9b26f30196c4852da75d9ad67b4ad9 (diff) |
PR11297: Provide a better diagnostic for code which contains a
reasonable-looking but ill-formed for-range statement of the form:
for (expression : expression)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147006 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseStmt.cpp')
-rw-r--r-- | lib/Parse/ParseStmt.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index 435bde3375..13b3bdaf74 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -1371,6 +1371,14 @@ StmtResult Parser::ParseForStatement(ParsedAttributes &attrs) { return StmtError(); } Collection = ParseExpression(); + } else if (getLang().CPlusPlus0x && Tok.is(tok::colon) && + !FirstPart.isInvalid()) { + // User tried to write the reasonable, but ill-formed, for-range-statement + // for (expr : expr) { ... } + Diag(Tok, diag::err_for_range_expected_decl) + << FirstPart.get()->getSourceRange(); + SkipUntil(tok::r_paren, false, true); + SecondPartIsInvalid = true; } else { if (!Value.isInvalid()) { Diag(Tok, diag::err_expected_semi_for); |