Fix #9421 (syntaxError on incomplete code (from z3)) (#2274)

This commit is contained in:
IOBYTE 2019-10-16 14:56:53 -04:00 committed by Daniel Marjamäki
parent 24211cf8b9
commit e4d2e9d2af
2 changed files with 7 additions and 1 deletions

View File

@ -6166,7 +6166,7 @@ void Tokenizer::simplifyFunctionParameters()
// Find the function e.g. foo( x ) or foo( x, y ) // Find the function e.g. foo( x ) or foo( x, y )
else if (Token::Match(tok, "%name% ( %name% [,)]") && else if (Token::Match(tok, "%name% ( %name% [,)]") &&
!(tok->strAt(-1) == ":" || tok->strAt(-1) == ",")) { !(tok->strAt(-1) == ":" || tok->strAt(-1) == "," || tok->strAt(-1) == "::")) {
// We have found old style function, now we need to change it // We have found old style function, now we need to change it
// First step: Get list of argument names in parentheses // First step: Get list of argument names in parentheses

View File

@ -226,6 +226,7 @@ private:
TEST_CASE(simplifyFunctionParameters1); // #3721 TEST_CASE(simplifyFunctionParameters1); // #3721
TEST_CASE(simplifyFunctionParameters2); // #4430 TEST_CASE(simplifyFunctionParameters2); // #4430
TEST_CASE(simplifyFunctionParameters3); // #4436 TEST_CASE(simplifyFunctionParameters3); // #4436
TEST_CASE(simplifyFunctionParameters4); // #9421
TEST_CASE(simplifyFunctionParametersMultiTemplate); TEST_CASE(simplifyFunctionParametersMultiTemplate);
TEST_CASE(simplifyFunctionParametersErrors); TEST_CASE(simplifyFunctionParametersErrors);
@ -3176,6 +3177,11 @@ private:
ASSERT_EQUALS(code, tokenizeAndStringify(code)); ASSERT_EQUALS(code, tokenizeAndStringify(code));
} }
void simplifyFunctionParameters4() { // #9421
const char code[] = "int foo :: bar ( int , int ) const ;";
ASSERT_EQUALS(code, tokenizeAndStringify(code));
}
void simplifyFunctionParametersMultiTemplate() { void simplifyFunctionParametersMultiTemplate() {
const char code[] = "template < typename T1 > template < typename T2 > " const char code[] = "template < typename T1 > template < typename T2 > "
"void A < T1 > :: foo ( T2 ) { }"; "void A < T1 > :: foo ( T2 ) { }";