Tokenizer: Bailout if @ is encountered in the code
This commit is contained in:
parent
3020e77570
commit
f4581d833d
|
@ -2169,6 +2169,18 @@ bool Tokenizer::tokenize(std::istream &code,
|
||||||
// Remove __asm..
|
// Remove __asm..
|
||||||
simplifyAsm();
|
simplifyAsm();
|
||||||
|
|
||||||
|
// When the assembly code has been cleaned up, no @ is allowed
|
||||||
|
for (const Token *tok = _tokens; tok; tok = tok->next())
|
||||||
|
{
|
||||||
|
if (tok->str() == "(")
|
||||||
|
tok = tok->link();
|
||||||
|
else if (tok->str()[0] == '@')
|
||||||
|
{
|
||||||
|
deallocateTokens();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove "volatile", "inline", "register", and "restrict"
|
// Remove "volatile", "inline", "register", and "restrict"
|
||||||
simplifyKeyword();
|
simplifyKeyword();
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ private:
|
||||||
TEST_CASE(tokenize10);
|
TEST_CASE(tokenize10);
|
||||||
TEST_CASE(tokenize11);
|
TEST_CASE(tokenize11);
|
||||||
TEST_CASE(tokenize12);
|
TEST_CASE(tokenize12);
|
||||||
|
TEST_CASE(tokenize13); // bailout if the code contains "@" - that is not handled well.
|
||||||
|
|
||||||
// don't freak out when the syntax is wrong
|
// don't freak out when the syntax is wrong
|
||||||
TEST_CASE(wrong_syntax);
|
TEST_CASE(wrong_syntax);
|
||||||
|
@ -469,6 +470,16 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// bailout if there is "@" - it is not handled well
|
||||||
|
void tokenize13()
|
||||||
|
{
|
||||||
|
const char code[] = "@implementation\n"
|
||||||
|
"-(Foo *)foo: (Bar *)bar\n"
|
||||||
|
"{ }\n"
|
||||||
|
"@end\n";
|
||||||
|
ASSERT_EQUALS("", tokenizeAndStringify(code));
|
||||||
|
}
|
||||||
|
|
||||||
void wrong_syntax()
|
void wrong_syntax()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue