Partial fix for #1475 (False positive: Not enough parameters for macro: #define A(a, b...))

http://sourceforge.net/apps/trac/cppcheck/ticket/1475
This commit is contained in:
Reijo Tomperi 2010-03-26 22:11:49 +02:00
parent 2eceaaefc0
commit 0cc84bd2be
2 changed files with 4 additions and 3 deletions

View File

@ -1598,7 +1598,9 @@ public:
{ {
if (str == _params[i]) if (str == _params[i])
{ {
if (_variadic && i == _params.size() - 1) if (_variadic &&
(i == _params.size() - 1 ||
(params2.size() + 2 == _params.size() && i + 1 == _params.size() - 1)))
{ {
str = ""; str = "";
for (unsigned int j = (unsigned int)_params.size() - 1; j < params2.size(); ++j) for (unsigned int j = (unsigned int)_params.size() - 1; j < params2.size(); ++j)

View File

@ -1300,8 +1300,7 @@ private:
"ABC(2,3);\n" "ABC(2,3);\n"
"ABC(4,5,6);\n"; "ABC(4,5,6);\n";
// When this TODO assertion works, #1475 is probably fixed ASSERT_EQUALS("\n\n\n1+0*0;\n2+03*0;\n4+05*06;\n", OurPreprocessor::expandMacros(filedata));
TODO_ASSERT_EQUALS("\n\n\n1 + 0 * 0\n2 + 03 * 0\n4 + 05 * 06\n", OurPreprocessor::expandMacros(filedata));
} }
{ {