Fixed #3770 (Segmentation fault in K&R function parameters simplification)
This commit is contained in:
parent
082e6d506b
commit
5d6a257c86
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue