Fixed #10013 (Tokenizer: Code with 'not' is not handled)
This commit is contained in:
parent
edd10064d1
commit
f08dde1140
|
@ -4701,6 +4701,9 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
|||
|
||||
removePragma();
|
||||
|
||||
// Simplify the C alternative tokens (and, or, etc.)
|
||||
simplifyCAlternativeTokens();
|
||||
|
||||
reportUnknownMacros();
|
||||
|
||||
simplifyHeadersAndUnusedTemplates();
|
||||
|
@ -4758,9 +4761,6 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
|||
// Combine tokens..
|
||||
combineOperators();
|
||||
|
||||
// Simplify the C alternative tokens (and, or, etc.)
|
||||
simplifyCAlternativeTokens();
|
||||
|
||||
// replace 'sin(0)' to '0' and other similar math expressions
|
||||
simplifyMathExpressions();
|
||||
|
||||
|
@ -7628,6 +7628,11 @@ bool Tokenizer::simplifyCAlternativeTokens()
|
|||
} else if (Token::Match(tok, "not|compl")) {
|
||||
alt.push_back(tok);
|
||||
|
||||
if (Token::Match(tok->previous(), "%assign%") || Token::Match(tok->next(), "%number%")) {
|
||||
replaceAll = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Don't simplify 'not p;' (in case 'not' is a type)
|
||||
if (!Token::Match(tok->next(), "%name%|(") ||
|
||||
Token::Match(tok->previous(), "[;{}]") ||
|
||||
|
|
|
@ -6319,6 +6319,8 @@ private:
|
|||
" char *or;\n"
|
||||
" while ((*or != 0) && (*or != '|')) or++;\n"
|
||||
"}", false, true, Settings::Native, "test.c"));
|
||||
// #10013
|
||||
ASSERT_EQUALS("void f ( ) { x = ! 123 ; }", tokenizeAndStringify("void f() { x = not 123; }", false, true, Settings::Native, "test.cpp"));
|
||||
}
|
||||
|
||||
void simplifyCalculations() {
|
||||
|
|
Loading…
Reference in New Issue