Fixed false positive #6453: Skip over inner class if checking outer function

This commit is contained in:
PKEuS 2015-01-27 21:21:03 +01:00
parent e56671101e
commit e82d2b3c8d
2 changed files with 15 additions and 1 deletions

View File

@ -39,7 +39,9 @@ void CheckVaarg::va_start_argument()
const Scope* scope = symbolDatabase->functionScopes[i];
const Function* function = scope->function;
for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
if (Token::simpleMatch(tok, "va_start (")) {
if (!tok->scope()->isExecutable())
tok = tok->scope()->classEnd;
else if (Token::simpleMatch(tok, "va_start (")) {
const Token* param2 = tok->tokAt(2)->nextArgument();
if (!param2)
continue;

View File

@ -90,6 +90,18 @@ private:
" va_end(arg_ptr);\n"
"}"); // Don't crash if less than expected arguments are given.
ASSERT_EQUALS("", errout.str());
check("void assertf_fail(const char *assertion, const char *file, int line, const char *func, const char* msg, ...) {\n"
" struct A {\n"
" A(char* buf, int size) {}\n"
" void printf(const char * format, ...) {\n"
" va_list args;\n"
" va_start(args, format);\n"
" va_end(args);\n"
" }\n"
" };\n"
"}"); // Inner class (#6453)
ASSERT_EQUALS("", errout.str());
}
void referenceAs_va_start() {