Merge pull request #613 from simartin/ticket_6536
Ticket #6536: Properly handle variables whose name is that of an allocation function.
This commit is contained in:
commit
0a49b033ba
|
@ -2745,7 +2745,7 @@ void CheckMemoryLeakNoVar::check()
|
||||||
void CheckMemoryLeakNoVar::checkForUnusedReturnValue(const Scope *scope)
|
void CheckMemoryLeakNoVar::checkForUnusedReturnValue(const Scope *scope)
|
||||||
{
|
{
|
||||||
for (const Token *tok = scope->classStart; tok != scope->classEnd; tok = tok->next()) {
|
for (const Token *tok = scope->classStart; tok != scope->classEnd; tok = tok->next()) {
|
||||||
if (Token::Match(tok, "%name% (") && (!tok->next()->astParent() || tok->next()->astParent()->str() == "!" || tok->next()->astParent()->isComparisonOp()) && tok->next()->astOperand1() == tok) {
|
if (!tok->varId() && Token::Match(tok, "%name% (") && (!tok->next()->astParent() || tok->next()->astParent()->str() == "!" || tok->next()->astParent()->isComparisonOp()) && tok->next()->astOperand1() == tok) {
|
||||||
const AllocType allocType = getAllocationType(tok, 0);
|
const AllocType allocType = getAllocationType(tok, 0);
|
||||||
if (allocType != No)
|
if (allocType != No)
|
||||||
returnValueNotUsedError(tok, tok->str());
|
returnValueNotUsedError(tok, tok->str());
|
||||||
|
|
|
@ -6194,6 +6194,7 @@ private:
|
||||||
|
|
||||||
void run() {
|
void run() {
|
||||||
settings.inconclusive = true;
|
settings.inconclusive = true;
|
||||||
|
settings.standards.posix = true;
|
||||||
settings.addEnabled("warning");
|
settings.addEnabled("warning");
|
||||||
|
|
||||||
LOAD_LIB_2(settings.library, "gtk.cfg");
|
LOAD_LIB_2(settings.library, "gtk.cfg");
|
||||||
|
@ -6374,6 +6375,13 @@ private:
|
||||||
" return foo;\n"
|
" return foo;\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// Ticket #6536
|
||||||
|
check("struct S { S(int) {} };\n"
|
||||||
|
"void foo(int i) {\n"
|
||||||
|
" S socket(i);\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void smartPointerFunctionParam() {
|
void smartPointerFunctionParam() {
|
||||||
|
|
Loading…
Reference in New Issue