fix syntax error for a.operator++() ? a.operator--() : 0 (#2382)

This commit is contained in:
IOBYTE 2019-11-20 16:13:32 -05:00 committed by amai2012
parent 98488790a1
commit df952926f8
2 changed files with 15 additions and 1 deletions

View File

@ -10815,7 +10815,7 @@ void Tokenizer::deleteSymbolDatabase()
bool Tokenizer::operatorEnd(const Token * tok) const
{
if (tok && tok->str() == ")") {
if (isFunctionHead(tok, "{|;"))
if (isFunctionHead(tok, "{|;|?|:"))
return true;
tok = tok->next();

View File

@ -408,6 +408,7 @@ private:
TEST_CASE(simplifyOperatorName21);
TEST_CASE(simplifyOperatorName22);
TEST_CASE(simplifyOperatorName23);
TEST_CASE(simplifyOperatorName24);
TEST_CASE(simplifyNullArray);
@ -6547,6 +6548,19 @@ private:
}
}
void simplifyOperatorName24() {
{
const char code[] = "void foo() { int i = a.operator++() ? a.operator--() : 0; }";
ASSERT_EQUALS("void foo ( ) { int i ; i = a . operator++ ( ) ? a . operator-- ( ) : 0 ; }",
tokenizeAndStringify(code));
}
{
const char code[] = "void foo() { int i = a.operator++(0) ? a.operator--(0) : 0; }";
ASSERT_EQUALS("void foo ( ) { int i ; i = a . operator++ ( 0 ) ? a . operator-- ( 0 ) : 0 ; }",
tokenizeAndStringify(code));
}
}
void simplifyNullArray() {
ASSERT_EQUALS("* ( foo . bar [ 5 ] ) = x ;", tokenizeAndStringify("0[foo.bar[5]] = x;"));
}