fix #2845 (segmentation fault of cppcheck)
This commit is contained in:
parent
f1782799cb
commit
db39f4364e
|
@ -9523,8 +9523,9 @@ void Tokenizer::simplifyBitfields()
|
||||||
offset = 1;
|
offset = 1;
|
||||||
|
|
||||||
Token *tok1 = tok->tokAt(2 + offset);
|
Token *tok1 = tok->tokAt(2 + offset);
|
||||||
if (tok1->tokAt(2)->isBoolean() || Token::Match(tok1->tokAt(2), "%num%") ||
|
if (tok1 && tok1->tokAt(2) &&
|
||||||
!Token::Match(tok1->tokAt(2), "public|protected|private| %type% ::|<|,|{|;"))
|
(tok1->tokAt(2)->isBoolean() || Token::Match(tok1->tokAt(2), "%num%") ||
|
||||||
|
!Token::Match(tok1->tokAt(2), "public|protected|private| %type% ::|<|,|{|;")))
|
||||||
{
|
{
|
||||||
while (tok1->next() && !Token::Match(tok1->next(), ";|,"))
|
while (tok1->next() && !Token::Match(tok1->next(), ";|,"))
|
||||||
tok1->deleteNext();
|
tok1->deleteNext();
|
||||||
|
|
|
@ -305,6 +305,7 @@ private:
|
||||||
TEST_CASE(bitfields8);
|
TEST_CASE(bitfields8);
|
||||||
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(microsoftMFC);
|
TEST_CASE(microsoftMFC);
|
||||||
|
|
||||||
|
@ -5356,6 +5357,14 @@ private:
|
||||||
ASSERT_EQUALS("{ } MACRO default : { } ;", tokenizeAndStringify(code,false));
|
ASSERT_EQUALS("{ } MACRO default : { } ;", tokenizeAndStringify(code,false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bitfields11() // ticket #2845 (segmentation fault)
|
||||||
|
{
|
||||||
|
const char code[] = "#if b&&a\n"
|
||||||
|
"#ifdef y z:\n";
|
||||||
|
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