File tree Expand file tree Collapse file tree 2 files changed +15
-11
lines changed
Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -10089,17 +10089,7 @@ void Tokenizer::simplifyBitfields()
1008910089 if (!Token::Match (tok, " ;|{|}|public:|protected:|private:" ))
1009010090 continue ;
1009110091
10092- bool isEnum = false ;
10093- if (tok->str () == " }" ) {
10094- const Token *type = tok->link ()->previous ();
10095- while (type && type->isName ()) {
10096- if (type->str () == " enum" ) {
10097- isEnum = true ;
10098- break ;
10099- }
10100- type = type->previous ();
10101- }
10102- }
10092+ const bool isEnum = tok->str () == " }" && isEnumStart (tok->link ());
1010310093
1010410094 const auto tooLargeError = [this ](const Token *tok) {
1010510095 const auto max = std::numeric_limits<short >::max ();
Original file line number Diff line number Diff line change @@ -4945,6 +4945,20 @@ class TestTokenizer : public TestFixture {
49454945 tokenizeAndStringify (" struct AB {\n "
49464946 " enum Foo {A,B} foo : 4;\n "
49474947 " };" ));
4948+
4949+ ASSERT_EQUALS (" struct S {\n " // #14324
4950+ " enum E : int { E0 , E1 } ; enum E e ;\n "
4951+ " } ;" ,
4952+ tokenizeAndStringify (" struct S {\n "
4953+ " enum E : int { E0, E1 } e : 2;\n "
4954+ " };\n " ));
4955+
4956+ ASSERT_EQUALS (" struct S {\n "
4957+ " enum class E : std :: uint8_t { E0 , E1 } ; enum E e ;\n "
4958+ " } ;" ,
4959+ tokenizeAndStringify (" struct S {\n "
4960+ " enum class E : std::uint8_t { E0, E1 } e : 2;\n "
4961+ " };\n " ));
49484962 }
49494963
49504964 void bitfields16 () {
You can’t perform that action at this time.
0 commit comments