Fixed #882 (false positive: uninitialized variable)

This commit is contained in:
Daniel Marjamäki 2009-11-02 18:31:22 +01:00
parent 4abbe9ffd4
commit 169bcfcff2
3 changed files with 17 additions and 3 deletions

View File

@ -553,11 +553,17 @@ void Preprocessor::removeAsm(std::string &str)
{
std::string::size_type pos = 0;
while ((pos = str.find("\nasm(", pos)) != std::string::npos)
_removeAsm(str, pos);
{
_removeAsm(str, pos++);
str.insert(pos, "asm()");
}
pos = 0;
while ((pos = str.find("\nasm (", pos)) != std::string::npos)
_removeAsm(str, pos);
{
_removeAsm(str, pos++);
str.insert(pos, "asm()");
}
pos = 0;
while ((pos = str.find("\nasm __volatile(", pos)) != std::string::npos)

View File

@ -981,6 +981,14 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
checkUninitVar("int a()\n"
"{\n"
" int ret;\n"
" asm();\n"
" return ret;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// if..
checkUninitVar("static void foo()\n"
"{\n"

View File

@ -832,7 +832,7 @@ private:
{
std::string str1("\nasm(\n\n\n);");
Preprocessor::removeAsm(str1);
ASSERT_EQUALS("\n\n\n\n;", str1);
ASSERT_EQUALS("\nasm()\n\n\n;", str1);
std::string str2("\nasm __volatile(\"\nlw iScale, 0x00(pScale)\n\", ());");
Preprocessor::removeAsm(str2);