diff --git a/lib/checkvaarg.cpp b/lib/checkvaarg.cpp index 4a248d0e4..23859b7df 100644 --- a/lib/checkvaarg.cpp +++ b/lib/checkvaarg.cpp @@ -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; diff --git a/test/testvaarg.cpp b/test/testvaarg.cpp index 777cf8063..e6dc84139 100644 --- a/test/testvaarg.cpp +++ b/test/testvaarg.cpp @@ -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() {