Fixed #8745 (Syntax error: AST broken (or))

This commit is contained in:
Daniel Marjamäki 2018-09-09 16:40:56 +02:00
parent 91a8807810
commit 404eb6c746
2 changed files with 4 additions and 0 deletions

View File

@ -6252,6 +6252,8 @@ bool Tokenizer::simplifyCAlternativeTokens()
if (cOpIt != cAlternativeTokens.end()) {
if (!Token::Match(tok->previous(), "%name%|%num%|%char%|)|]|> %name% %name%|%num%|%char%|%op%|("))
continue;
if (Token::Match(tok->next(), "%assign%|%or%|%oror%|&&|*|/|%|^"))
continue;
tok->str(cOpIt->second);
ret = true;
} else if (Token::Match(tok, "not|compl")) {

View File

@ -5950,6 +5950,8 @@ private:
ASSERT_EQUALS("void f ( ) { if ( not = x ) { } }", tokenizeAndStringify("void f() { if (not=x){} }", false, true, Settings::Native, "test.cpp"));
// #8029
ASSERT_EQUALS("void f ( struct S * s ) { x = s . and + 1 ; }", tokenizeAndStringify("void f(struct S *s) { x = s->and + 1; }", false, true, Settings::Native, "test.c"));
// #8745
ASSERT_EQUALS("void f ( ) { if ( x ) { or = 0 ; } }", tokenizeAndStringify("void f() { if (x) or = 0; }"));
}
void simplifyCalculations() {