Fixed false positive va_list_usedBeforeStarted (#7527)
This commit is contained in:
parent
3eb0e9b6c0
commit
9a61559eca
|
@ -122,7 +122,7 @@ void CheckVaarg::va_list_usage()
|
|||
}
|
||||
open = nopen;
|
||||
tok = tok->linkAt(1);
|
||||
} else if (Token::Match(tok, "throw|return"))
|
||||
} else if (Token::Match(tok, "throw|return|break"))
|
||||
exitOnEndOfStatement = true;
|
||||
else if (_tokenizer->isCPP() && tok->str() == "try") {
|
||||
open = false;
|
||||
|
|
|
@ -200,6 +200,22 @@ private:
|
|||
" va_end(v2);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #7527
|
||||
check("void foo(int flag1, int flag2, ...) {\n"
|
||||
" switch (flag1) {\n"
|
||||
" default:\n"
|
||||
" va_list vargs;\n"
|
||||
" va_start(vargs, flag2);\n"
|
||||
" if (flag2) {\n"
|
||||
" va_end(vargs);\n"
|
||||
" break;\n"
|
||||
" }\n"
|
||||
" int data = va_arg(vargs, int);\n"
|
||||
" va_end(vargs);\n"
|
||||
" }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void va_start_subsequentCalls() {
|
||||
|
|
Loading…
Reference in New Issue