Fix another issue related to #647 (Crash during tokenizing (wrong) K&R function declaration)
http://sourceforge.net/apps/trac/cppcheck/ticket/647
This commit is contained in:
parent
a3d9863725
commit
75a65a02a8
|
@ -2321,6 +2321,7 @@ void Tokenizer::simplifyFunctionParameters()
|
|||
|
||||
// Replace "x" with "int x" or similar
|
||||
Token::replace(argumentNames[tok->str()], start, tok);
|
||||
argumentNames.erase(tok->str());
|
||||
tok = temp;
|
||||
start = tok;
|
||||
}
|
||||
|
|
|
@ -1370,11 +1370,21 @@ private:
|
|||
void argumentsWithSameName()
|
||||
{
|
||||
// This code has syntax error, two variables can not have the same name
|
||||
const char code[] = "void foo(x, x)\n"
|
||||
" int x;\n"
|
||||
" int x;\n"
|
||||
"{}\n";
|
||||
ASSERT_EQUALS("void foo ( x , x ) int x ; int x ; { }", tok(code));
|
||||
{
|
||||
const char code[] = "void foo(x, x)\n"
|
||||
" int x;\n"
|
||||
" int x;\n"
|
||||
"{}\n";
|
||||
ASSERT_EQUALS("void foo ( x , x ) int x ; int x ; { }", tok(code));
|
||||
}
|
||||
|
||||
{
|
||||
const char code[] = "void foo(x, y)\n"
|
||||
" int x;\n"
|
||||
" int x;\n"
|
||||
"{}\n";
|
||||
ASSERT_EQUALS("void foo ( int x , y ) int x ; { }", tok(code));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue