Uninitialized variables: fixed false positives when using pointer aliasing

This commit is contained in:
Daniel Marjamäki 2010-01-11 19:25:01 +01:00
parent 94d5e32aa1
commit b8b6b0ec32
2 changed files with 14 additions and 0 deletions

View File

@ -1859,6 +1859,11 @@ private:
use_pointer(foundError, checks, &tok); use_pointer(foundError, checks, &tok);
return &tok; return &tok;
} }
if (Token::simpleMatch(tok.previous(), "&"))
{
ExecutionPath::bailOutVar(checks, tok.varId());
}
} }
return &tok; return &tok;
} }

View File

@ -1150,6 +1150,15 @@ private:
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void a()\n"
"{\n"
" int x;\n"
" int *y = &x;\n"
" *y = 0;\n"
" x++;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
checkUninitVar("int a()\n" checkUninitVar("int a()\n"
"{\n" "{\n"
" int ret;\n" " int ret;\n"