diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index ea2d3b507..e8ecf1e93 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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()); diff --git a/test/testgarbage.cpp b/test/testgarbage.cpp index 6ea33889c..2782ae82c 100644 --- a/test/testgarbage.cpp +++ b/test/testgarbage.cpp @@ -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 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"