Fixed #8774 (Wrong handling of function with name 'or')
This commit is contained in:
parent
2a2fa49098
commit
c84ba10b37
|
@ -7064,6 +7064,13 @@ bool Tokenizer::simplifyCAlternativeTokens()
|
||||||
continue;
|
continue;
|
||||||
if (Token::Match(tok->next(), "%assign%|%or%|%oror%|&&|*|/|%|^") && !Token::Match(tok->previous(), "%num%|%char% %name% *"))
|
if (Token::Match(tok->next(), "%assign%|%or%|%oror%|&&|*|/|%|^") && !Token::Match(tok->previous(), "%num%|%char% %name% *"))
|
||||||
continue;
|
continue;
|
||||||
|
if (executableScopeLevel == 0 && Token::Match(tok, "%name% (")) {
|
||||||
|
const Token *start = tok;
|
||||||
|
while (Token::Match(start, "%name%|*"))
|
||||||
|
start = start->previous();
|
||||||
|
if (!start || Token::Match(start, "[;}]"))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
tok->str(cOpIt->second);
|
tok->str(cOpIt->second);
|
||||||
ret = true;
|
ret = true;
|
||||||
} else if (Token::Match(tok, "not|compl")) {
|
} else if (Token::Match(tok, "not|compl")) {
|
||||||
|
|
|
@ -6143,6 +6143,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void simplifyCAlternativeTokens() {
|
void simplifyCAlternativeTokens() {
|
||||||
|
ASSERT_EQUALS("void or ( ) ;", tokenizeAndStringify("void or(void);", false, true, Settings::Native, "test.c"));
|
||||||
ASSERT_EQUALS("void f ( ) { if ( a && b ) { ; } }", tokenizeAndStringify("void f() { if (a and b); }", false, true, Settings::Native, "test.c"));
|
ASSERT_EQUALS("void f ( ) { if ( a && b ) { ; } }", tokenizeAndStringify("void f() { if (a and b); }", false, true, Settings::Native, "test.c"));
|
||||||
ASSERT_EQUALS("void f ( ) { if ( a && b ) { ; } }", tokenizeAndStringify("void f() { if (a and b); }", false, true, Settings::Native, "test.cpp"));
|
ASSERT_EQUALS("void f ( ) { if ( a && b ) { ; } }", tokenizeAndStringify("void f() { if (a and b); }", false, true, Settings::Native, "test.cpp"));
|
||||||
ASSERT_EQUALS("void f ( ) { if ( a || b ) { ; } }", tokenizeAndStringify("void f() { if (a or b); }", false, true, Settings::Native, "test.c"));
|
ASSERT_EQUALS("void f ( ) { if ( a || b ) { ; } }", tokenizeAndStringify("void f() { if (a or b); }", false, true, Settings::Native, "test.c"));
|
||||||
|
|
Loading…
Reference in New Issue