#6751 segmentation fault (invalid code) in Tokenizer::simplifyTypedef.

This commit is contained in:
amai2012 2015-06-03 11:39:30 +02:00
parent ed5a4127e8
commit 87bf09c0ae
2 changed files with 7 additions and 0 deletions

View File

@ -1061,7 +1061,9 @@ void Tokenizer::simplifyTypedef()
// check for operator typedef // check for operator typedef
/** @todo add support for multi-token operators */ /** @todo add support for multi-token operators */
else if (tok2->str() == "operator" && else if (tok2->str() == "operator" &&
tok2->next() &&
tok2->next()->str() == typeName->str() && tok2->next()->str() == typeName->str() &&
tok2->linkAt(2) &&
tok2->strAt(2) == "(" && tok2->strAt(2) == "(" &&
Token::Match(tok2->linkAt(2), ") const| {")) { Token::Match(tok2->linkAt(2), ") const| {")) {
// check for qualifier // check for qualifier

View File

@ -112,6 +112,7 @@ private:
TEST_CASE(garbageCode71); TEST_CASE(garbageCode71);
TEST_CASE(garbageCode72); TEST_CASE(garbageCode72);
TEST_CASE(garbageCode73); TEST_CASE(garbageCode73);
TEST_CASE(garbageCode74);
TEST_CASE(garbageValueFlow); TEST_CASE(garbageValueFlow);
TEST_CASE(garbageSymbolDatabase); TEST_CASE(garbageSymbolDatabase);
@ -625,6 +626,10 @@ private:
ASSERT_THROW(checkCode("typedef int IRT[2]; IRT&"), InternalError); ASSERT_THROW(checkCode("typedef int IRT[2]; IRT&"), InternalError);
} }
void garbageCode74() { // #6751
checkCode("_lenraw(const char* digits) { } typedef decltype(sizeof(0)) { } operator");
}
void garbageValueFlow() { void garbageValueFlow() {
// #6089 // #6089
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n" const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"