parent
f9134a69d2
commit
c7cd091a93
|
@ -821,7 +821,14 @@ namespace {
|
|||
}
|
||||
}
|
||||
|
||||
Token* const tok2 = insertTokens(tok, mRangeType);
|
||||
// don't add class|struct|union in inheritance list
|
||||
auto rangeType = mRangeType;
|
||||
if (Token::Match(tok->previous(), "public|private|protected")) {
|
||||
while (Token::Match(rangeType.first, "const|class|struct|union"))
|
||||
rangeType.first = rangeType.first->next();
|
||||
}
|
||||
|
||||
Token* const tok2 = insertTokens(tok, rangeType);
|
||||
Token* const tok3 = insertTokens(tok2, mRangeTypeQualifiers);
|
||||
|
||||
Token *after = tok3;
|
||||
|
|
|
@ -3044,6 +3044,7 @@ private:
|
|||
TEST_CASE(deallocuse2);
|
||||
TEST_CASE(fclose_false_positive); // #9575
|
||||
TEST_CASE(strcpy_false_negative);
|
||||
TEST_CASE(doubleFree);
|
||||
}
|
||||
|
||||
void returnedValue() { // #9298
|
||||
|
@ -3089,6 +3090,15 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Memory leak: buf\n", errout.str());
|
||||
}
|
||||
|
||||
void doubleFree() {
|
||||
check("void f(char* p) {\n"
|
||||
" free(p);\n"
|
||||
" printf(\"%s\", p = strdup(\"abc\"));\n"
|
||||
" free(p);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestLeakAutoVarStrcpy)
|
||||
|
|
|
@ -1608,6 +1608,31 @@ private:
|
|||
ASSERT_EQUALS(expected, tok(code));
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
const char code[] = "struct B {};\n" // #12141
|
||||
"typedef struct B B;\n"
|
||||
"namespace N {\n"
|
||||
" struct D : public B {};\n"
|
||||
"}\n";
|
||||
|
||||
const char expected[] = "struct B { } ; namespace N { struct D : public B { } ; }";
|
||||
ASSERT_EQUALS(expected, tok(code));
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
const char code[] = "struct B {};\n"
|
||||
"typedef const struct B CB;\n"
|
||||
"namespace N {\n"
|
||||
" struct D : public CB {};\n"
|
||||
"}\n"
|
||||
"CB cb;\n";
|
||||
|
||||
const char expected[] = "struct B { } ; namespace N { struct D : public B { } ; } const struct B cb ;";
|
||||
ASSERT_EQUALS(expected, tok(code));
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
}
|
||||
|
||||
void simplifyTypedef45() {
|
||||
|
|
Loading…
Reference in New Issue