Fixed #4226 (False positive: Uninitialized variable (problem with namespace ::rtl))

This commit is contained in:
Daniel Marjamäki 2012-10-15 06:53:38 +02:00
parent 9e147c4a0a
commit 562291477d
2 changed files with 20 additions and 5 deletions

View File

@ -4955,6 +4955,11 @@ void Tokenizer::simplifyVarDecl(bool only_k_r_fpar)
Token *tok2 = type0;
unsigned int typelen = 1;
if (tok2->str() == "::") {
tok2 = tok2->next();
typelen++;
}
//check if variable is declared 'const' or 'static' or both
while (tok2) {
if (!Token::Match(tok2, "const|static") && Token::Match(tok2, "%type% const|static")) {

View File

@ -5197,14 +5197,24 @@ private:
"}", tokenizeAndStringify(code));
}
void vardecl21() { // #4042
const char code[] = "void f() {\n"
" a::b const *p = 0;\n"
"}\n";
void vardecl21() { // type in namespace
// #4042 - a::b const *p = 0;
const char code1[] = "void f() {\n"
" a::b const *p = 0;\n"
"}\n";
ASSERT_EQUALS("void f ( ) {\n"
"a :: b const * p ; p = 0 ;\n"
"}"
, tokenizeAndStringify(code));
, tokenizeAndStringify(code1));
// #4226 - ::a::b const *p = 0;
const char code2[] = "void f() {\n"
" ::a::b const *p = 0;\n"
"}\n";
ASSERT_EQUALS("void f ( ) {\n"
":: a :: b const * p ; p = 0 ;\n"
"}"
, tokenizeAndStringify(code2));
}
void vardecl22() { // #4211 - segmentation fault