fix #2706 (Analysis failed. If the code is valid then please report this failure.)

This commit is contained in:
Robert Reif 2011-04-04 22:18:12 -04:00
parent af632a6aa0
commit 23e4f020e9
2 changed files with 19 additions and 2 deletions

View File

@ -9363,8 +9363,11 @@ void Tokenizer::simplifyBitfields()
if (tok->next()->str() == "const")
offset = 1;
Token::eraseTokens(tok->tokAt(0), tok->tokAt(5 + offset));
tok = tok->previous();
if (tok->strAt(3 + offset) != "{")
{
Token::eraseTokens(tok->tokAt(0), tok->tokAt(5 + offset));
tok = tok->previous();
}
}
if (last && last->str() == ",")

View File

@ -296,6 +296,7 @@ private:
TEST_CASE(bitfields6); // ticket #2595
TEST_CASE(bitfields7); // ticket #1987
TEST_CASE(bitfields8);
TEST_CASE(bitfields9); // ticket #2706
TEST_CASE(microsoftMFC);
@ -5373,6 +5374,19 @@ private:
ASSERT_EQUALS("", errout.str());
}
void bitfields9() // ticket #2706
{
const char code[] = "void f() {\n"
" goto half;\n"
"half:\n"
" {\n"
" ;\n"
" }\n"
"};";
tokenizeAndStringify(code,false);
ASSERT_EQUALS("", errout.str());
}
void microsoftMFC()
{
const char code1[] = "class MyDialog : public CDialog { DECLARE_MESSAGE_MAP() private: CString text; };";