Fixed #1504 (False positive: Cppcheck incorrectly reports that extern variable is not initialized)

This commit is contained in:
Daniel Marjamäki 2010-03-20 08:03:18 +01:00
parent 3d90559035
commit 5b1b845750
2 changed files with 12 additions and 0 deletions

View File

@ -4333,6 +4333,12 @@ void Tokenizer::unsignedint()
continue;
}
if (Token::Match(tok->previous(), "extern unsigned|signed *| %var% [;[]"))
{
tok->str("int");
continue;
}
// signed int a; -> int a;
if (Token::Match(tok, "signed %type% %var% [;,=)]"))
{

View File

@ -2734,6 +2734,12 @@ private:
ASSERT_EQUALS(code2, tokenizeAndStringify(code1));
}
// "extern unsigned x;" => "extern int x;"
{
const char code1[] = "; extern unsigned x;";
const char code2[] = "; extern int x ;";
ASSERT_EQUALS(code2, tokenizeAndStringify(code1));
}
}
void unsigned2()