diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-09-18 00:52:05 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-09-18 00:52:05 +0000 |
commit | 0875c53239dde03319099d8ae4ac12a4025709e8 (patch) | |
tree | 7649b32a1e208b22e0d951a72764cb8ba0697347 /clang/lib/Parse/Parser.cpp | |
parent | 5657555357af46e44a1970f7a7aa8f5ced35aa79 (diff) | |
download | bcm5719-llvm-0875c53239dde03319099d8ae4ac12a4025709e8.tar.gz bcm5719-llvm-0875c53239dde03319099d8ae4ac12a4025709e8.zip |
If a comma operator is followed by a token which unambiguously indicates the
start of a statement or the end of a compound-statement, diagnose the comma as
a typo for a semicolon. Patch by Ahmed Bougacha! Additional test cases and
minor refactoring by me.
llvm-svn: 164085
Diffstat (limited to 'clang/lib/Parse/Parser.cpp')
-rw-r--r-- | clang/lib/Parse/Parser.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index 4c40b8e974d..2b19c973cee 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -154,7 +154,8 @@ void Parser::SuggestParentheses(SourceLocation Loc, unsigned DK, static bool IsCommonTypo(tok::TokenKind ExpectedTok, const Token &Tok) { switch (ExpectedTok) { - case tok::semi: return Tok.is(tok::colon); // : for ; + case tok::semi: + return Tok.is(tok::colon) || Tok.is(tok::comma); // : or , for ; default: return false; } } |