#7131 crash: Tokenizer::setVarId()

This commit is contained in:
Alexander Mai 2015-11-14 21:22:53 +01:00
parent bda9c8c2d5
commit 835c234e18
2 changed files with 11 additions and 0 deletions

View File

@ -2886,6 +2886,8 @@ void Tokenizer::setVarId()
do { do {
tok3 = tok3->tokAt(2); tok3 = tok3->tokAt(2);
} while (Token::Match(tok3, ":: %name%")); } while (Token::Match(tok3, ":: %name%"));
if (!tok3)
syntaxError(tok2);
const std::string& str3 = tok3->str(); const std::string& str3 = tok3->str();
if (str3 == "(") if (str3 == "(")
allMemberFunctions.push_back(tok2); allMemberFunctions.push_back(tok2);

View File

@ -205,6 +205,7 @@ private:
TEST_CASE(garbageCode154); // #7112 TEST_CASE(garbageCode154); // #7112
TEST_CASE(garbageCode155); // #7118 TEST_CASE(garbageCode155); // #7118
TEST_CASE(garbageCode156); // #7120 TEST_CASE(garbageCode156); // #7120
TEST_CASE(garbageCode157); // #7131
TEST_CASE(garbageValueFlow); TEST_CASE(garbageValueFlow);
TEST_CASE(garbageSymbolDatabase); TEST_CASE(garbageSymbolDatabase);
@ -1232,6 +1233,14 @@ private:
checkCode("struct {}a; d f() { c ? : } {}a.p"); checkCode("struct {}a; d f() { c ? : } {}a.p");
} }
void garbageCode157() { // #7131
ASSERT_THROW(checkCode("namespace std {\n"
" template < typename >\n"
" void swap(); \n"
"}"
"template std::swap\n"), InternalError);
}
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"