Fixed #6556 (Tokenizer::simplifyVarDecl: doesn't simplify template variables properly)
This commit is contained in:
parent
21ab4413aa
commit
f705cdce72
|
@ -5637,7 +5637,16 @@ void Tokenizer::simplifyVarDecl(Token * tokBegin, Token * tokEnd, bool only_k_r_
|
||||||
tok2 = tok2->next();
|
tok2 = tok2->next();
|
||||||
if (tok2 && tok2->str() != ",")
|
if (tok2 && tok2->str() != ",")
|
||||||
tok2 = nullptr;
|
tok2 = nullptr;
|
||||||
} else
|
}
|
||||||
|
|
||||||
|
// parenthesis, functions can't be declared like:
|
||||||
|
// int f1(a,b), f2(c,d);
|
||||||
|
// so if there is a comma assume this is a variable declaration
|
||||||
|
else if (Token::Match(varName, "%name% (") && Token::simpleMatch(varName->linkAt(1), ") ,")) {
|
||||||
|
tok2 = varName->linkAt(1)->next();
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
tok2 = nullptr;
|
tok2 = nullptr;
|
||||||
} else {
|
} else {
|
||||||
tok2 = nullptr;
|
tok2 = nullptr;
|
||||||
|
|
|
@ -294,7 +294,8 @@ private:
|
||||||
TEST_CASE(vardecl_template_2);
|
TEST_CASE(vardecl_template_2);
|
||||||
TEST_CASE(vardecl_union);
|
TEST_CASE(vardecl_union);
|
||||||
TEST_CASE(vardecl_par); // #2743 - set links if variable type contains parentheses
|
TEST_CASE(vardecl_par); // #2743 - set links if variable type contains parentheses
|
||||||
TEST_CASE(vardecl_par2) // #3912 - set correct links
|
TEST_CASE(vardecl_par2); // #3912 - set correct links
|
||||||
|
TEST_CASE(vardecl_par3); // #6556 - Fred x1(a), x2(b);
|
||||||
TEST_CASE(volatile_variables);
|
TEST_CASE(volatile_variables);
|
||||||
TEST_CASE(syntax_error);
|
TEST_CASE(syntax_error);
|
||||||
TEST_CASE(syntax_error_templates_1);
|
TEST_CASE(syntax_error_templates_1);
|
||||||
|
@ -3816,6 +3817,12 @@ private:
|
||||||
tokenizer.validate();
|
tokenizer.validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vardecl_par3() {
|
||||||
|
// ticket #6556- Fred x1(a), x2(b);
|
||||||
|
const char code[] = "Fred x1(a), x2(b);";
|
||||||
|
ASSERT_EQUALS("Fred x1 ( a ) ; Fred x2 ( b ) ;", tokenizeAndStringify(code));
|
||||||
|
}
|
||||||
|
|
||||||
void vardec_static() {
|
void vardec_static() {
|
||||||
{
|
{
|
||||||
// don't simplify declarations of static variables
|
// don't simplify declarations of static variables
|
||||||
|
|
Loading…
Reference in New Issue