Fixed #2873 (segmentation fault of cppcheck while scanning rose-compiler suite)
This commit is contained in:
parent
597733bec4
commit
cf3ab649fb
|
@ -4962,7 +4962,7 @@ bool Tokenizer::simplifyIfAddBraces()
|
||||||
{
|
{
|
||||||
for (Token *tok = _tokens; tok; tok = tok ? tok->next() : NULL)
|
for (Token *tok = _tokens; tok; tok = tok ? tok->next() : NULL)
|
||||||
{
|
{
|
||||||
if (tok->str() == "(")
|
if (tok->str() == "(" && !Token::Match(tok->previous(), "[;{}]"))
|
||||||
{
|
{
|
||||||
tok = tok->link();
|
tok = tok->link();
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -5705,6 +5705,15 @@ private:
|
||||||
{
|
{
|
||||||
tokenizeAndStringify("if()x");
|
tokenizeAndStringify("if()x");
|
||||||
ASSERT_EQUALS("[test.cpp:1]: (error) syntax error\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:1]: (error) syntax error\n", errout.str());
|
||||||
|
|
||||||
|
// ticket #2873
|
||||||
|
{
|
||||||
|
const char code[] = "void f() { "
|
||||||
|
"( { if(*p) (*p) = x(); } ) "
|
||||||
|
"}";
|
||||||
|
ASSERT_EQUALS("void f ( ) { ( { if ( * p ) { ( * p ) = x ( ) ; } } ) }",
|
||||||
|
tokenizeAndStringify(code));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue