diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 5bc04196cff..8e60a31fede 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -10022,6 +10022,10 @@ void Tokenizer::simplifyBitfields() Token* typeTok = tok->next(); while (Token::Match(typeTok, "const|volatile")) typeTok = typeTok->next(); + if (Token::Match(typeTok, ":: %name%")) + typeTok = typeTok->next(); + while (Token::Match(typeTok, "%name% :: %name%")) + typeTok = typeTok->tokAt(2); if (Token::Match(typeTok, "%type% %name% :") && !Token::Match(tok->next(), "case|public|protected|private|class|struct") && !Token::simpleMatch(tok->tokAt(2), "default :")) { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 116b2873f24..b6abf31b424 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -305,6 +305,8 @@ class TestTokenizer : public TestFixture { TEST_CASE(bitfields16); // Save bitfield bit count TEST_CASE(bitfields17); TEST_CASE(bitfields18); + TEST_CASE(bitfields19); // ticket #13733 + TEST_CASE(bitfields20); TEST_CASE(simplifyNamespaceStd); @@ -4858,6 +4860,16 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("[test.cpp:1:29]: (warning) Bit-field size exceeds max number of bits 32767 [tooLargeBitField]\n", errout_str()); } + void bitfields19() { + const char code[] = "struct S { volatile std::uint32_t a : 10; };"; + ASSERT_EQUALS("struct S { volatile std :: uint32_t a ; } ;", tokenizeAndStringify(code)); + } + + void bitfields20() { + const char code[] = "struct S { volatile ::uint32_t a : 10; };"; + ASSERT_EQUALS("struct S { volatile :: uint32_t a ; } ;", tokenizeAndStringify(code)); + } + void simplifyNamespaceStd() { const char *expected;