Fixed crash #5511.

This commit is contained in:
PKEuS 2014-03-17 11:50:45 +01:00
parent 86e6bb430a
commit 50f6bb5d36
2 changed files with 6 additions and 1 deletions

View File

@ -7369,7 +7369,7 @@ void Tokenizer::simplifyEnum()
if (tok->next()->str() == ":") {
tok = tok->next();
if (!tok->next()) {
if (!tok->next() || !tok->next()->isName()) {
syntaxError(tok);
return; // can't recover
}

View File

@ -79,6 +79,7 @@ private:
TEST_CASE(garbageCode5); // #5168
TEST_CASE(garbageCode6); // #5214
TEST_CASE(garbageCode7);
TEST_CASE(garbageCode8); // #5511
TEST_CASE(simplifyFileAndLineMacro); // tokenize "return - __LINE__;"
@ -1025,6 +1026,10 @@ private:
tokenizeAndStringify("foo(Args&&...) fn void = { } auto template<typename... bar(Args&&...)", /*simplify=*/true);
}
void garbageCode8() {
tokenizeAndStringify("{ enum struct : };", true);
}
void simplifyFileAndLineMacro() { // tokenize 'return - __LINE__' correctly
ASSERT_EQUALS("\"test.cpp\"", tokenizeAndStringify("__FILE__"));
ASSERT_EQUALS("return -1 ;", tokenizeAndStringify("return - __LINE__;"));