diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index f0c3c742b..d98ed81e4 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5311,20 +5311,27 @@ bool Tokenizer::simplifyFunctionParameters() tok1 = tok1->next(); } - if (bailOut) { + if (bailOut || !tok1) { tok = tok->link(); continue; } - //the two containers should hold the same size.. + //the two containers may not hold the same size... + //in that case, the missing parameters are defined as 'int' if (argumentNames.size() != argumentNames2.size()) { - tok = tok->link(); - //error if the second container is not empty - if (!argumentNames2.empty()) { - syntaxError(tok); - return false; + //move back 'tok1' to the last ';' + tok1 = tok1->previous(); + std::map::iterator it; + for (it = argumentNames.begin(); it != argumentNames.end(); ++it) { + if (argumentNames2.find(it->first) == argumentNames2.end()) { + //add the missing parameter argument declaration + tok1->insertToken(";"); + tok1->insertToken(it->first); + //register the change inside argumentNames2 + argumentNames2[it->first] = tok1->next(); + tok1->insertToken("int"); + } } - continue; } while (tok->str() != ")") { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 70613862e..c6b467b55 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -4088,13 +4088,6 @@ private: tokenizeAndStringify("void foo(int, int)\n" "{}\n"); ASSERT_EQUALS("", errout.str()); - - //non-matching arguments after round braces - tokenizeAndStringify("void foo(x, y, z)\n" - " int x;\n" - " int y;\n" - "{}\n"); - ASSERT_EQUALS("[test.cpp:1]: (error) syntax error\n", errout.str()); } // Simplify "((..))" into "(..)"