Fixed #5339 (Tokenizer::setVarId : function-pointer function argument not getting variable id, causing FP)

This commit is contained in:
Heinrich Schuchardt 2014-01-12 15:15:09 +01:00 committed by Daniel Marjamäki
parent 3d79613f2b
commit f6510a6b45
2 changed files with 8 additions and 1 deletions

View File

@ -5152,7 +5152,7 @@ void Tokenizer:: simplifyFunctionPointers()
} }
// check for start of statement // check for start of statement
else if (tok->previous() && !Token::Match(tok->previous(), "{|}|;|(|public:|protected:|private:")) else if (tok->previous() && !Token::Match(tok->previous(), "{|}|;|,|(|public:|protected:|private:"))
continue; continue;
if (Token::Match(tok, "%type% *| *| ( * %var% [| ]| ) (")) if (Token::Match(tok, "%type% *| *| ( * %var% [| ]| ) ("))

View File

@ -420,6 +420,8 @@ private:
TEST_CASE(simplifyFunctorCall); TEST_CASE(simplifyFunctorCall);
TEST_CASE(simplifyFunctionPointer); // ticket #5339 (simplify function pointer after comma)
TEST_CASE(redundant_semicolon); TEST_CASE(redundant_semicolon);
TEST_CASE(simplifyFunctionReturn); TEST_CASE(simplifyFunctionReturn);
@ -8019,6 +8021,11 @@ private:
ASSERT_EQUALS("IncrementFunctor ( ) ( a ) ;", tok("IncrementFunctor()(a);", true)); ASSERT_EQUALS("IncrementFunctor ( ) ( a ) ;", tok("IncrementFunctor()(a);", true));
} }
// #ticket #5339 (simplify function pointer after comma)
void simplifyFunctionPointer() {
ASSERT_EQUALS("f ( double x , double * y ) ;", tok("f (double x, double (*y) ());", true));
}
void redundant_semicolon() { void redundant_semicolon() {
ASSERT_EQUALS("void f ( ) { ; }", tok("void f() { ; }", false)); ASSERT_EQUALS("void f ( ) { ; }", tok("void f() { ; }", false));
ASSERT_EQUALS("void f ( ) { ; }", tok("void f() { do { ; } while (0); }", true)); ASSERT_EQUALS("void f ( ) { ; }", tok("void f() { do { ; } while (0); }", true));