Tokenizer::simplifyVarDecl: Don't simplify inside parenhteses

This commit is contained in:
Daniel Marjamäki 2012-02-18 15:05:29 +01:00
parent 4b52df675a
commit a118f82ca7
3 changed files with 13 additions and 1 deletions

View File

@ -5101,6 +5101,8 @@ void Tokenizer::simplifyVarDecl(bool only_k_r_fpar)
continue; continue;
} else } else
continue; continue;
} else if (tok->str() == "(") {
tok = tok->link();
} }
if (tok->previous() && !Token::Match(tok->previous(), "{|}|;|)|public:|protected:|private:")) if (tok->previous() && !Token::Match(tok->previous(), "{|}|;|)|public:|protected:|private:"))

View File

@ -287,6 +287,7 @@ private:
TEST_CASE(vardecl15); TEST_CASE(vardecl15);
TEST_CASE(vardecl16); TEST_CASE(vardecl16);
TEST_CASE(vardecl17); TEST_CASE(vardecl17);
TEST_CASE(vardecl18);
TEST_CASE(vardecl_stl_1); TEST_CASE(vardecl_stl_1);
TEST_CASE(vardecl_stl_2); TEST_CASE(vardecl_stl_2);
TEST_CASE(vardecl_template); TEST_CASE(vardecl_template);
@ -4636,6 +4637,16 @@ private:
"a < b > :: c :: d :: e < f > y ; y = bar ( ) ;", tokenizeAndStringify(code)); "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() { void volatile_variables() {
const char code[] = "volatile int a=0;\n" const char code[] = "volatile int a=0;\n"
"volatile int b=0;\n" "volatile int b=0;\n"

View File

@ -2056,7 +2056,6 @@ private:
" int a, a2, a2*x; if () ;\n" " int a, a2, a2*x; if () ;\n"
" )\n" " )\n"
"}\n"); "}\n");
ASSERT_EQUALS("[test.cpp:5]: (error) Uninitialized variable: a2\n", errout.str());
} }
}; };