Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10078,17 +10078,7 @@ void Tokenizer::simplifyBitfields()
if (!Token::Match(tok, ";|{|}|public:|protected:|private:"))
continue;

bool isEnum = false;
if (tok->str() == "}") {
const Token *type = tok->link()->previous();
while (type && type->isName()) {
if (type->str() == "enum") {
isEnum = true;
break;
}
type = type->previous();
}
}
const bool isEnum = tok->str() == "}" && isEnumStart(tok->link());

const auto tooLargeError = [this](const Token *tok) {
const auto max = std::numeric_limits<short>::max();
Expand Down
14 changes: 14 additions & 0 deletions test/testtokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4939,6 +4939,20 @@ class TestTokenizer : public TestFixture {
tokenizeAndStringify("struct AB {\n"
" enum Foo {A,B} foo : 4;\n"
"};"));

ASSERT_EQUALS("struct S {\n" // #14324
"enum E : int { E0 , E1 } ; enum E e ;\n"
"} ;",
tokenizeAndStringify("struct S {\n"
" enum E : int { E0, E1 } e : 2;\n"
"};\n"));

ASSERT_EQUALS("struct S {\n"
"enum class E : std :: uint8_t { E0 , E1 } ; enum E e ;\n"
"} ;",
tokenizeAndStringify("struct S {\n"
" enum class E : std::uint8_t { E0, E1 } e : 2;\n"
"};\n"));
}

void bitfields16() {
Expand Down
Loading