Fixed crash on invalid code #6080

This commit is contained in:
PKEuS 2014-08-23 12:36:42 +02:00
parent 7f2be2f57c
commit 0dc4b75565
2 changed files with 7 additions and 1 deletions

View File

@ -93,7 +93,7 @@ void CheckExceptionSafety::deallocThrow()
tok = tok->next();
if (Token::simpleMatch(tok, "[ ]"))
tok = tok->tokAt(2);
if (!tok)
if (!tok || tok == scope->classEnd)
break;
if (!Token::Match(tok, "%var% ;"))
continue;

View File

@ -49,6 +49,8 @@ private:
TEST_CASE(nothrowAttributeThrow);
TEST_CASE(nothrowAttributeThrow2); // #5703
TEST_CASE(nothrowDeclspecThrow);
TEST_CASE(garbage);
}
void check(const char code[], bool inconclusive = false) {
@ -411,6 +413,10 @@ private:
check("const char *func() __attribute((nothrow)); void func1() { return 0; }\n");
ASSERT_EQUALS("", errout.str());
}
void garbage() {
check("{ } A() { delete }"); // #6080
}
};
REGISTER_TEST(TestExceptionSafety)