From 0cc84bd2be9d41959c342ce449f7e3ea7866251b Mon Sep 17 00:00:00 2001 From: Reijo Tomperi Date: Fri, 26 Mar 2010 22:11:49 +0200 Subject: [PATCH] Partial fix for #1475 (False positive: Not enough parameters for macro: #define A(a, b...)) http://sourceforge.net/apps/trac/cppcheck/ticket/1475 --- lib/preprocessor.cpp | 4 +++- test/testpreprocessor.cpp | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 492b56761..0e61382bb 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -1598,7 +1598,9 @@ public: { 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 = ""; for (unsigned int j = (unsigned int)_params.size() - 1; j < params2.size(); ++j) diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index 8a37f84b4..5da07e4b1 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -1300,8 +1300,7 @@ private: "ABC(2,3);\n" "ABC(4,5,6);\n"; - // When this TODO assertion works, #1475 is probably fixed - TODO_ASSERT_EQUALS("\n\n\n1 + 0 * 0\n2 + 03 * 0\n4 + 05 * 06\n", OurPreprocessor::expandMacros(filedata)); + ASSERT_EQUALS("\n\n\n1+0*0;\n2+03*0;\n4+05*06;\n", OurPreprocessor::expandMacros(filedata)); } {