Merge branch 'master' of github.com:danmar/cppcheck

This commit is contained in:
Kimmo Varis 2010-08-31 22:05:08 +03:00
commit 9a52b35144
3 changed files with 21 additions and 3 deletions

View File

@ -1634,7 +1634,6 @@ void CheckOther::functionVariableUsage()
else
{
Variables::VariableUsage *var = variables.find(varid1);
if (var && var->_type == Variables::reference)
{
variables.writeAliases(varid1);
@ -1642,6 +1641,13 @@ void CheckOther::functionVariableUsage()
}
else
variables.write(varid1);
Variables::VariableUsage *var2 = variables.find(tok->varId());
if (var2 && var2->_type == Variables::reference)
{
variables.writeAliases(tok->varId());
variables.read(tok->varId());
}
}
const Token *equal = tok->next();

View File

@ -3403,7 +3403,7 @@ void Tokenizer::simplifySizeof()
{
Token tempTok(0);
tempTok.str("*");
sizeOfVar[varId] = MathLib::toString<long>(sizeOfType(&tempTok));
sizeOfVar[varId] = MathLib::toString<unsigned long>(sizeOfType(&tempTok));
}
else if (Token::Match(tok->tokAt(-1), "%type% %var% [ ] = %str% ;"))
@ -3547,7 +3547,7 @@ void Tokenizer::simplifySizeof()
if (Token::Match(tok->next(), "( * )"))
{
tok->str(MathLib::toString<long>(sizeOfType(tok->tokAt(2))));
tok->str(MathLib::toString<unsigned long>(sizeOfType(tok->tokAt(2))));
Token::eraseTokens(tok, tok->tokAt(4));
}

View File

@ -81,6 +81,7 @@ private:
TEST_CASE(localvaralias7); // ticket #1732
TEST_CASE(localvaralias8);
TEST_CASE(localvaralias9); // ticket #1996
TEST_CASE(localvaralias10); // ticket #2004
TEST_CASE(localvarasm);
TEST_CASE(localvarstatic);
@ -2146,6 +2147,17 @@ private:
ASSERT_EQUALS("", errout.str());
}
void localvaralias10() // ticket 2004
{
functionVariableUsage("void foo(Foo &foo)\n"
"{\n"
" Foo &ref = foo;\n"
" int *x = &ref.x();\n"
" *x = 0;\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void localvarasm()
{
functionVariableUsage("void foo(int &b)\n"