fix invalid bitfield match and simplification that created invalid code
This commit is contained in:
parent
15fc071514
commit
dc0dfea079
|
@ -9316,7 +9316,7 @@ void Tokenizer::simplifyBitfields()
|
||||||
Token *last = 0;
|
Token *last = 0;
|
||||||
|
|
||||||
if (Token::Match(tok, ";|{|}|public:|protected:|private: const| %type% %var% :") &&
|
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;
|
int offset = 0;
|
||||||
if (tok->next()->str() == "const")
|
if (tok->next()->str() == "const")
|
||||||
|
|
|
@ -291,6 +291,7 @@ private:
|
||||||
TEST_CASE(bitfields5); // ticket #1956
|
TEST_CASE(bitfields5); // ticket #1956
|
||||||
TEST_CASE(bitfields6); // ticket #2595
|
TEST_CASE(bitfields6); // ticket #2595
|
||||||
TEST_CASE(bitfields7); // ticket #1987
|
TEST_CASE(bitfields7); // ticket #1987
|
||||||
|
TEST_CASE(bitfields8);
|
||||||
|
|
||||||
TEST_CASE(microsoftMFC);
|
TEST_CASE(microsoftMFC);
|
||||||
|
|
||||||
|
@ -5300,6 +5301,22 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
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()
|
void microsoftMFC()
|
||||||
{
|
{
|
||||||
const char code1[] = "class MyDialog : public CDialog { DECLARE_MESSAGE_MAP() private: CString text; };";
|
const char code1[] = "class MyDialog : public CDialog { DECLARE_MESSAGE_MAP() private: CString text; };";
|
||||||
|
|
Loading…
Reference in New Issue