Ticket #6704: Tighten pattern skipping base class declarations and fix crash upon garbage code.

This commit is contained in:
Simon Martin 2015-05-24 08:16:34 +02:00
parent af8d258d11
commit 26f244e638
2 changed files with 6 additions and 1 deletions

View File

@ -2792,7 +2792,7 @@ void Tokenizer::setVarId()
const Token* tokStart = tok->tokAt(2);
while (tokStart && tokStart->str() != "{") {
if (Token::Match(tokStart, "public|private|protected"))
if (Token::Match(tokStart, "public|private|protected %name%"))
tokStart = tokStart->next();
if (tokStart->strAt(1) == "," || tokStart->strAt(1) == "{")
varlist[classname].insert(varlist[tokStart->str()].begin(), varlist[tokStart->str()].end());

View File

@ -82,6 +82,7 @@ private:
TEST_CASE(garbageCode41); // #6685
TEST_CASE(garbageCode42); // #5760
TEST_CASE(garbageCode43); // #6703
TEST_CASE(garbageCode44); // #6704
TEST_CASE(garbageValueFlow);
TEST_CASE(garbageSymbolDatabase);
@ -475,6 +476,10 @@ private:
checkCode("int { }; struct A<void> a = { }");
}
void garbageCode44() { // #6704
ASSERT_THROW(checkCode("{ { }; }; { class A : }; public typedef b;"), InternalError);
}
void garbageValueFlow() {
// #6089
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"