File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -123,6 +123,20 @@ static bool isExecutableScope(const Token* tok)
123123 return false ;
124124}
125125
126+ static bool isEnumDefinition (const Token* tok)
127+ {
128+ if (!Token::Match (tok, " enum class| %name% {|:" ))
129+ return false ;
130+ while (!Token::Match (tok, " [{:]" ))
131+ tok = tok->next ();
132+ if (tok->str () == " {" )
133+ return true ;
134+ tok = tok->next (); // skip ':'
135+ while (Token::Match (tok, " %name%|::" ))
136+ tok = tok->next ();
137+ return Token::simpleMatch (tok, " {" );
138+ }
139+
126140void SymbolDatabase::createSymbolDatabaseFindAllScopes ()
127141{
128142 // create global scope
@@ -163,8 +177,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
163177 if ((tok->isCpp () && tok->isKeyword () &&
164178 ((Token::Match (tok, " class|struct|union|namespace ::| %name% final| {|:|::|<" ) &&
165179 !Token::Match (tok->previous (), " new|friend|const|enum|typedef|mutable|volatile|using|)|(|<" )) ||
166- (Token::Match (tok, " enum class| %name% {" ) ||
167- Token::Match (tok, " enum class| %name% : %name% ::|{" ))))
180+ isEnumDefinition (tok)))
168181 || (tok->isC () && tok->isKeyword () && Token::Match (tok, " struct|union|enum %name% {" ))) {
169182 const Token *tok2 = tok->tokAt (2 );
170183
Original file line number Diff line number Diff line change @@ -6372,6 +6372,7 @@ class TestSymbolDatabase : public TestFixture {
63726372 void enum17 () {
63736373 {
63746374 GET_SYMBOL_DB (" struct S {\n " // #12564
6375+ " enum class E : std::uint8_t;\n "
63756376 " enum class E : std::uint8_t { E0 };\n "
63766377 " static void f(S::E e) {\n "
63776378 " if (e == S::E::E0) {}\n "
You can’t perform that action at this time.
0 commit comments