diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index f630a4c0a..b4badf102 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9316,7 +9316,7 @@ void Tokenizer::simplifyBitfields() Token *last = 0; if (Token::Match(tok, ";|{|}|public:|protected:|private: const| %type% %var% :") && - !Token::Match(tok->next(), "case|public|protected|private")) + !Token::Match(tok->next(), "case|public|protected|private|class|struct")) { int offset = 0; if (tok->next()->str() == "const") diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 5406b6bf6..e0ded16e9 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -291,6 +291,7 @@ private: TEST_CASE(bitfields5); // ticket #1956 TEST_CASE(bitfields6); // ticket #2595 TEST_CASE(bitfields7); // ticket #1987 + TEST_CASE(bitfields8); TEST_CASE(microsoftMFC); @@ -5300,6 +5301,22 @@ private: ASSERT_EQUALS("", errout.str()); } + void bitfields8() + { + const char code[] = "struct A;" + "class B : virtual public C" + "{" + " int f();" + "};"; + const char expected[] = "struct A ; " + "class B : virtual public C " + "{ " + "int f ( ) ; " + "} ;"; + ASSERT_EQUALS(expected, tokenizeAndStringify(code,false)); + ASSERT_EQUALS("", errout.str()); + } + void microsoftMFC() { const char code1[] = "class MyDialog : public CDialog { DECLARE_MESSAGE_MAP() private: CString text; };";