Merge pull request #293 from simartin/ticket_5709

Ticket #5709: Comma operator not properly tokenized.
This commit is contained in:
Daniel Marjamäki 2014-05-04 11:46:04 +02:00
commit 5edb6092a1
2 changed files with 8 additions and 1 deletions

View File

@ -7086,6 +7086,7 @@ bool Tokenizer::simplifyRedundantParentheses()
while (Token::Match(tok->previous(), "[{([,] ( !!{") &&
Token::Match(tok->link(), ") [;,])]") &&
!Token::simpleMatch(tok->tokAt(-2), "operator ,") && // Ticket #5709
!Token::findsimplematch(tok, ",", tok->link())) {
// We have "( ... )", remove the parentheses
tok->link()->deleteThis();
@ -10161,7 +10162,7 @@ void Tokenizer::simplifyOperatorName()
}
done = false;
}
if (Token::Match(par, ".|%op%")) {
if (Token::Match(par, ".|%op%|,")) {
op += par->str();
par = par->next();
done = false;

View File

@ -507,6 +507,7 @@ private:
TEST_CASE(simplifyOperatorName6); // ticket #3194
TEST_CASE(simplifyOperatorName7); // ticket #4619
TEST_CASE(simplifyOperatorName8); // ticket #5706
TEST_CASE(simplifyOperatorName9); // ticket #5709 - comma operator not properly tokenized
TEST_CASE(simplifyNull);
@ -8173,6 +8174,11 @@ private:
ASSERT_EQUALS(result6, tokenizeAndStringify(code6,false));
}
void simplifyOperatorName9() { // Ticket #5709
const char code[] = "struct R { R operator, ( R b ) ; } ;";
ASSERT_EQUALS(code, tokenizeAndStringify(code));
}
void simplifyNull() {
ASSERT_EQUALS("if ( ! p )", tokenizeAndStringify("if (p==NULL)"));
ASSERT_EQUALS("f ( NULL ) ;", tokenizeAndStringify("f(NULL);"));