Merge branch 'master' of http://github.com/danmar/cppcheck
This commit is contained in:
commit
daef8ef5fd
|
@ -608,7 +608,7 @@ void CheckNullPointer::nullPointerByCheckAndDeRef()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Token::Match(tok2, "goto|return|continue|break|throw|if"))
|
if (Token::Match(tok2, "goto|return|continue|break|throw|if|switch"))
|
||||||
{
|
{
|
||||||
if (Token::Match(tok2, "return * %varid%", varid))
|
if (Token::Match(tok2, "return * %varid%", varid))
|
||||||
nullPointerError(tok2, tok->strAt(3));
|
nullPointerError(tok2, tok->strAt(3));
|
||||||
|
|
|
@ -217,11 +217,13 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
||||||
function.isPure = true;
|
function.isPure = true;
|
||||||
|
|
||||||
// count the number of constructors
|
// count the number of constructors
|
||||||
if (function.type == Function::eConstructor || function.type == Function::eCopyConstructor)
|
if (function.type == Function::eConstructor ||
|
||||||
|
function.type == Function::eCopyConstructor)
|
||||||
scope->numConstructors++;
|
scope->numConstructors++;
|
||||||
|
|
||||||
// assume implementation is inline (definition and implementation same)
|
// assume implementation is inline (definition and implementation same)
|
||||||
function.token = function.tokenDef;
|
function.token = function.tokenDef;
|
||||||
|
function.arg = function.argDef;
|
||||||
|
|
||||||
// out of line function
|
// out of line function
|
||||||
if (Token::Match(end, ") const| ;") ||
|
if (Token::Match(end, ") const| ;") ||
|
||||||
|
@ -238,7 +240,6 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
||||||
{
|
{
|
||||||
function.isInline = true;
|
function.isInline = true;
|
||||||
function.hasBody = true;
|
function.hasBody = true;
|
||||||
function.arg = function.argDef;
|
|
||||||
|
|
||||||
scope->functionList.push_back(function);
|
scope->functionList.push_back(function);
|
||||||
|
|
||||||
|
@ -831,6 +832,7 @@ void SymbolDatabase::addNewFunction(Scope **scope, const Token **tok)
|
||||||
// syntax error?
|
// syntax error?
|
||||||
if (!new_scope->classEnd)
|
if (!new_scope->classEnd)
|
||||||
{
|
{
|
||||||
|
(*scope)->nestedList.pop_back();
|
||||||
delete new_scope;
|
delete new_scope;
|
||||||
while (tok1->next())
|
while (tok1->next())
|
||||||
tok1 = tok1->next();
|
tok1 = tok1->next();
|
||||||
|
@ -848,6 +850,7 @@ void SymbolDatabase::addNewFunction(Scope **scope, const Token **tok)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
(*scope)->nestedList.pop_back();
|
||||||
delete new_scope;
|
delete new_scope;
|
||||||
*scope = NULL;
|
*scope = NULL;
|
||||||
*tok = NULL;
|
*tok = NULL;
|
||||||
|
|
|
@ -2408,6 +2408,17 @@ bool Tokenizer::tokenize(std::istream &code,
|
||||||
// typedef..
|
// typedef..
|
||||||
simplifyTypedef();
|
simplifyTypedef();
|
||||||
|
|
||||||
|
// Fix internal error by updating links (#2376)
|
||||||
|
// TODO: Remove this "createLinks". Make sure that the testcase
|
||||||
|
// TestSimplifyTokens::simplifyTypedefFunction8
|
||||||
|
// doesn't fail.
|
||||||
|
if (!createLinks())
|
||||||
|
{
|
||||||
|
// Source has syntax errors, can't proceed
|
||||||
|
cppcheckError(0);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// enum..
|
// enum..
|
||||||
simplifyEnum();
|
simplifyEnum();
|
||||||
|
|
||||||
|
|
|
@ -868,6 +868,19 @@ private:
|
||||||
" fred->a();\n"
|
" fred->a();\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// #2493 - switch
|
||||||
|
check("void f(Fred *fred) {\n"
|
||||||
|
" if (fred == NULL) {\n"
|
||||||
|
" x = 0;\n"
|
||||||
|
" }\n"
|
||||||
|
" switch (x) {\n"
|
||||||
|
" case 1:\n"
|
||||||
|
" fred->a();\n"
|
||||||
|
" break;\n"
|
||||||
|
" };\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test CheckNullPointer::nullConstantDereference
|
// Test CheckNullPointer::nullConstantDereference
|
||||||
|
|
|
@ -243,6 +243,7 @@ private:
|
||||||
TEST_CASE(simplifyTypedefFunction5);
|
TEST_CASE(simplifyTypedefFunction5);
|
||||||
TEST_CASE(simplifyTypedefFunction6);
|
TEST_CASE(simplifyTypedefFunction6);
|
||||||
TEST_CASE(simplifyTypedefFunction7);
|
TEST_CASE(simplifyTypedefFunction7);
|
||||||
|
TEST_CASE(simplifyTypedefFunction8);
|
||||||
|
|
||||||
TEST_CASE(reverseArraySyntax)
|
TEST_CASE(reverseArraySyntax)
|
||||||
TEST_CASE(simplify_numeric_condition)
|
TEST_CASE(simplify_numeric_condition)
|
||||||
|
@ -5440,6 +5441,15 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void simplifyTypedefFunction8()
|
||||||
|
{
|
||||||
|
// #2376 - internal error
|
||||||
|
const char code[] = "typedef int f_expand(const nrv_byte *);\n"
|
||||||
|
"void f(f_expand *(*get_fexp(int))){}\n";
|
||||||
|
checkSimplifyTypedef(code);
|
||||||
|
ASSERT_EQUALS("", errout.str()); // make sure that there is no internal error
|
||||||
|
}
|
||||||
|
|
||||||
void reverseArraySyntax()
|
void reverseArraySyntax()
|
||||||
{
|
{
|
||||||
ASSERT_EQUALS("a [ 13 ]", tok("13[a]"));
|
ASSERT_EQUALS("a [ 13 ]", tok("13[a]"));
|
||||||
|
|
|
@ -799,6 +799,7 @@ private:
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
TODO_ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: pItem\n", errout.str());
|
TODO_ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: pItem\n", errout.str());
|
||||||
|
ASSERT_EQUALS("", errout.str()); // current result
|
||||||
}
|
}
|
||||||
|
|
||||||
// switch..
|
// switch..
|
||||||
|
|
Loading…
Reference in New Issue