Tokenizer::simplifyVarDecl: Don't simplify inside parenhteses
This commit is contained in:
parent
4b52df675a
commit
a118f82ca7
|
@ -5101,6 +5101,8 @@ void Tokenizer::simplifyVarDecl(bool only_k_r_fpar)
|
|||
continue;
|
||||
} else
|
||||
continue;
|
||||
} else if (tok->str() == "(") {
|
||||
tok = tok->link();
|
||||
}
|
||||
|
||||
if (tok->previous() && !Token::Match(tok->previous(), "{|}|;|)|public:|protected:|private:"))
|
||||
|
|
|
@ -287,6 +287,7 @@ private:
|
|||
TEST_CASE(vardecl15);
|
||||
TEST_CASE(vardecl16);
|
||||
TEST_CASE(vardecl17);
|
||||
TEST_CASE(vardecl18);
|
||||
TEST_CASE(vardecl_stl_1);
|
||||
TEST_CASE(vardecl_stl_2);
|
||||
TEST_CASE(vardecl_template);
|
||||
|
@ -4636,6 +4637,16 @@ private:
|
|||
"a < b > :: c :: d :: e < f > y ; y = bar ( ) ;", tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
void vardecl18() {
|
||||
const char code[] = "void f() {\n"
|
||||
" g((double)v1*v2, v3, v4);\n"
|
||||
"}\n";
|
||||
|
||||
ASSERT_EQUALS("void f ( ) {\n"
|
||||
"g ( ( double ) v1 * v2 , v3 , v4 ) ;\n"
|
||||
"}", tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
void volatile_variables() {
|
||||
const char code[] = "volatile int a=0;\n"
|
||||
"volatile int b=0;\n"
|
||||
|
|
|
@ -2056,7 +2056,6 @@ private:
|
|||
" int a, a2, a2*x; if () ;\n"
|
||||
" )\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (error) Uninitialized variable: a2\n", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue