Fixed #3770 (Segmentation fault in K&R function parameters simplification)

This commit is contained in:
Edoardo Prezioso 2012-04-29 12:58:12 +02:00
parent 082e6d506b
commit 5d6a257c86
2 changed files with 17 additions and 0 deletions

View File

@ -4830,6 +4830,10 @@ bool Tokenizer::simplifyFunctionParameters()
std::map<std::string, Token *> argumentNames2;
while (tok1 && tok1->str() != "{") {
if (tok1->str() == "(" || tok1->str() == ")") {
bailOut = true;
break;
}
if (tok1->str() == ";") {
if (tokparam) {
syntaxError(tokparam);

View File

@ -4157,6 +4157,19 @@ private:
"}";
ASSERT_EQUALS("void foo ( ) { if ( x ) { } { } }", tokenizeAndStringify(code, true));
}
// #3770 - Don't segfault and don't change macro argument as if it's a K&R function argument
{
const char code[] = "MACRO(a)"
""
"void f()"
"{"
" SetLanguage();"
" {"
" }"
"}";
ASSERT_EQUALS("MACRO ( a ) void f ( ) { SetLanguage ( ) ; { } }", tokenizeAndStringify(code, true));
}
}
void simplifyFunctionParameters1() { // ticket #3721