Fix #881 (Tokenizer: Something seems to be wrong in Tokenizer::simplifyKnownVariables)
http://sourceforge.net/apps/trac/cppcheck/ticket/881
This commit is contained in:
parent
87800185c4
commit
7fc72484ec
|
@ -3461,7 +3461,7 @@ bool Tokenizer::simplifyKnownVariables()
|
|||
ret = true;
|
||||
}
|
||||
|
||||
if (Token::Match(tok3->next(), "%varid% ++|--", varid))
|
||||
if (Token::Match(tok3->next(), "%varid% ++|--", varid) && MathLib::isInt(value))
|
||||
{
|
||||
const std::string op(tok3->strAt(2));
|
||||
if (Token::Match(tok3, "[{};] %any% %any% ;"))
|
||||
|
|
|
@ -82,6 +82,7 @@ private:
|
|||
TEST_CASE(simplifyKnownVariables14);
|
||||
TEST_CASE(simplifyKnownVariables15);
|
||||
TEST_CASE(simplifyKnownVariables16);
|
||||
TEST_CASE(simplifyKnownVariables17);
|
||||
|
||||
TEST_CASE(match1);
|
||||
|
||||
|
@ -837,6 +838,15 @@ private:
|
|||
simplifyKnownVariables(code);
|
||||
}
|
||||
|
||||
void simplifyKnownVariables17()
|
||||
{
|
||||
// ticket #807 - segmentation fault when macro isn't found
|
||||
const char code[] = "void f ( ) { char *s = malloc(100);mp_ptr p = s; p++; }";
|
||||
ASSERT_EQUALS(
|
||||
"void f ( ) { char * s ; s = malloc ( 100 ) ; mp_ptr p ; p = s ; p ++ ; }",
|
||||
simplifyKnownVariables(code));
|
||||
}
|
||||
|
||||
void match1()
|
||||
{
|
||||
// Match "%var% | %var%"
|
||||
|
|
Loading…
Reference in New Issue