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:
Reijo Tomperi 2009-09-05 23:41:39 +03:00
parent a3d9863725
commit 75a65a02a8
2 changed files with 16 additions and 5 deletions

View File

@ -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;
}

View File

@ -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));
}
}
};