diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 994513c09..83366a8ba 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -4648,7 +4648,7 @@ const Token * Scope::addEnum(const Token * tok, bool isCpp) if (tok2 == end) { tok2 = tok2->next(); - if (tok2 && tok2->str() != ";") + if (tok2 && tok2->str() != ";" && (isCpp || tok2->str() != ")")) tok2 = nullptr; } else tok2 = nullptr; diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 4015bd0c9..3887b1b9c 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -376,6 +376,7 @@ private: TEST_CASE(enum7); TEST_CASE(enum8); TEST_CASE(enum9); + TEST_CASE(enum10); // #11001 TEST_CASE(sizeOfType); @@ -5307,6 +5308,19 @@ private: ASSERT_EQUALS(X1->value, 8); } + void enum10() { // #11001 + GET_SYMBOL_DB_C("int b = sizeof(enum etag {X, Y});\n"); + ASSERT(db != nullptr); + const Enumerator *X = db->scopeList.back().findEnumerator("X"); + ASSERT(X); + ASSERT(X->value_known); + ASSERT_EQUALS(X->value, 0); + const Enumerator *Y = db->scopeList.back().findEnumerator("Y"); + ASSERT(Y); + ASSERT(Y->value_known); + ASSERT_EQUALS(Y->value, 1); + } + void sizeOfType() { // #7615 - crash in Symboldatabase::sizeOfType() GET_SYMBOL_DB("enum e;\n"