Fixed #3502 (segmentation fault of cppcheck (struct{x y:};))
This commit is contained in:
parent
e39b70c1be
commit
9eb1a5864b
|
@ -8580,8 +8580,11 @@ void Tokenizer::simplifyBitfields()
|
|||
if (tok1 && tok1->tokAt(2) &&
|
||||
(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(), "[;,)]{}]")) {
|
||||
if (Token::Match(tok1->next(), "[([]"))
|
||||
Token::eraseTokens(tok1, tok1->next()->link());
|
||||
tok1->deleteNext();
|
||||
}
|
||||
|
||||
last = tok1->next();
|
||||
}
|
||||
|
|
|
@ -344,6 +344,7 @@ private:
|
|||
TEST_CASE(bitfields10);
|
||||
TEST_CASE(bitfields11); // ticket #2845 (segmentation fault)
|
||||
TEST_CASE(bitfields12); // ticket #3485 (segmentation fault)
|
||||
TEST_CASE(bitfields13); // ticket #3502 (segmentation fault)
|
||||
|
||||
TEST_CASE(microsoftMFC);
|
||||
TEST_CASE(microsoftMemory);
|
||||
|
@ -5707,6 +5708,10 @@ private:
|
|||
ASSERT_EQUALS("{ } ;", tokenizeAndStringify(code,false));
|
||||
}
|
||||
|
||||
void bitfields13() { // ticket #3502 (segmentation fault)
|
||||
ASSERT_EQUALS("x y ;", tokenizeAndStringify("struct{x y:};\n",false));
|
||||
}
|
||||
|
||||
void microsoftMFC() {
|
||||
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));
|
||||
|
|
Loading…
Reference in New Issue