Fixed ticket #3485 (segmentation fault of cppcheck ( {a:1;}; ))
This commit is contained in:
parent
54f54761b4
commit
2dd53ec966
|
@ -8950,7 +8950,13 @@ void Tokenizer::simplifyAsm()
|
||||||
// Simplify bitfields
|
// Simplify bitfields
|
||||||
void Tokenizer::simplifyBitfields()
|
void Tokenizer::simplifyBitfields()
|
||||||
{
|
{
|
||||||
|
bool goback = false;
|
||||||
for (Token *tok = _tokens; tok; tok = tok->next()) {
|
for (Token *tok = _tokens; tok; tok = tok->next()) {
|
||||||
|
|
||||||
|
if (goback) {
|
||||||
|
goback = false;
|
||||||
|
tok = tok->previous();
|
||||||
|
}
|
||||||
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% :") &&
|
||||||
|
@ -8971,7 +8977,7 @@ void Tokenizer::simplifyBitfields()
|
||||||
|
|
||||||
if (tok->strAt(3 + offset) != "{") {
|
if (tok->strAt(3 + offset) != "{") {
|
||||||
tok->deleteNext(4+offset);
|
tok->deleteNext(4+offset);
|
||||||
tok = tok->previous();
|
goback = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -342,6 +342,7 @@ private:
|
||||||
TEST_CASE(bitfields9); // ticket #2706
|
TEST_CASE(bitfields9); // ticket #2706
|
||||||
TEST_CASE(bitfields10);
|
TEST_CASE(bitfields10);
|
||||||
TEST_CASE(bitfields11); // ticket #2845 (segmentation fault)
|
TEST_CASE(bitfields11); // ticket #2845 (segmentation fault)
|
||||||
|
TEST_CASE(bitfields12); // ticket #3485 (segmentation fault)
|
||||||
|
|
||||||
TEST_CASE(microsoftMFC);
|
TEST_CASE(microsoftMFC);
|
||||||
TEST_CASE(microsoftMemory);
|
TEST_CASE(microsoftMemory);
|
||||||
|
@ -5691,6 +5692,11 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bitfields12() { // ticket #3485 (segmentation fault)
|
||||||
|
const char code[] = "{a:1;};\n";
|
||||||
|
ASSERT_EQUALS("{ } ;", tokenizeAndStringify(code,false));
|
||||||
|
}
|
||||||
|
|
||||||
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; };";
|
||||||
ASSERT_EQUALS("class MyDialog : public CDialog { private: CString text ; } ;", tokenizeAndStringify(code1,false,true,Settings::Win32A));
|
ASSERT_EQUALS("class MyDialog : public CDialog { private: CString text ; } ;", tokenizeAndStringify(code1,false,true,Settings::Win32A));
|
||||||
|
|
Loading…
Reference in New Issue