Fix #894 (Invalid line number in "Invalid number of character")
http://sourceforge.net/apps/trac/cppcheck/ticket/894
This commit is contained in:
parent
c3dff9a6d3
commit
00b62442b6
|
@ -1565,21 +1565,21 @@ bool Tokenizer::createLinks()
|
|||
if (links.size() > 0)
|
||||
{
|
||||
// Error, { and } don't match.
|
||||
syntaxError(_tokens, '{');
|
||||
syntaxError(links.back(), '{');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (links2.size() > 0)
|
||||
{
|
||||
// Error, ( and ) don't match.
|
||||
syntaxError(_tokens, '(');
|
||||
syntaxError(links2.back(), '(');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (links3.size() > 0)
|
||||
{
|
||||
// Error, [ and ] don't match.
|
||||
syntaxError(_tokens, '[');
|
||||
syntaxError(links3.back(), '[');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -524,7 +524,7 @@ private:
|
|||
Tokenizer tokenizer(0, this);
|
||||
std::istringstream istr(src);
|
||||
ASSERT_EQUALS(false, tokenizer.tokenize(istr, "test.cpp"));
|
||||
ASSERT_EQUALS("[test.cpp:1]: (error) Invalid number of character ((). Can't process file.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Invalid number of character ((). Can't process file.\n", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2356,6 +2356,42 @@ private:
|
|||
tokenizer.simplifyTokenList();
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
errout.str("");
|
||||
const char code[] = "void f()\n"
|
||||
"{\n"
|
||||
" foo(;\n"
|
||||
"}\n";
|
||||
Tokenizer tokenizer(0, this);
|
||||
std::istringstream istr(code);
|
||||
ASSERT_EQUALS(false, tokenizer.tokenize(istr, "test.cpp"));
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Invalid number of character ((). Can't process file.\n", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
errout.str("");
|
||||
const char code[] = "void f()\n"
|
||||
"{\n"
|
||||
" for(;;){ foo();\n"
|
||||
"}\n";
|
||||
Tokenizer tokenizer(0, this);
|
||||
std::istringstream istr(code);
|
||||
ASSERT_EQUALS(false, tokenizer.tokenize(istr, "test.cpp"));
|
||||
ASSERT_EQUALS("[test.cpp:2]: (error) Invalid number of character ({). Can't process file.\n", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
errout.str("");
|
||||
const char code[] = "void f()\n"
|
||||
"{\n"
|
||||
" a[10;\n"
|
||||
"}\n";
|
||||
Tokenizer tokenizer(0, this);
|
||||
std::istringstream istr(code);
|
||||
ASSERT_EQUALS(false, tokenizer.tokenize(istr, "test.cpp"));
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Invalid number of character ([). Can't process file.\n", errout.str());
|
||||
}
|
||||
}
|
||||
|
||||
void removeKeywords()
|
||||
|
|
Loading…
Reference in New Issue