From 0875c53239dde03319099d8ae4ac12a4025709e8 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 18 Sep 2012 00:52:05 +0000 Subject: 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 --- clang/lib/Parse/Parser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'clang/lib/Parse/Parser.cpp') 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; } } -- cgit v1.2.3