File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1306,6 +1306,8 @@ void CheckIO::checkFormatString(const Token * const tok,
13061306 // Count printf/scanf parameters..
13071307 int numFunction = 0 ;
13081308 while (argListTok2) {
1309+ if (Token::Match (argListTok2, " %name% ..." )) // bailout for parameter pack
1310+ return ;
13091311 numFunction++;
13101312 argListTok2 = argListTok2->nextArgument (); // Find next argument
13111313 }
Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ class TestIO : public TestFixture {
8080 TEST_CASE (testPrintfAuto); // #8992
8181 TEST_CASE (testPrintfParenthesis); // #8489
8282 TEST_CASE (testStdDistance); // #10304
83+ TEST_CASE (testParameterPack); // #11289
8384 }
8485
8586#define check (...) check_(__FILE__, __LINE__, __VA_ARGS__)
@@ -4868,6 +4869,16 @@ class TestIO : public TestFixture {
48684869 " }" , /* inconclusive*/ false , /* portability*/ true );
48694870 ASSERT_EQUALS (" " , errout.str ());
48704871 }
4872+
4873+ void testParameterPack () { // #11289
4874+ check (" template <typename... Args> auto f(const char* format, const Args&... args) {\n "
4875+ " return snprintf(nullptr, 0, format, args...);\n "
4876+ " }\n "
4877+ " void g() {\n "
4878+ " f(\" %d%d\" , 1, 2);\n "
4879+ " }\n " );
4880+ ASSERT_EQUALS (" " , errout.str ());
4881+ }
48714882};
48724883
48734884REGISTER_TEST (TestIO)
You can’t perform that action at this time.
0 commit comments