Fixed #2087 (False positive: Array 'str[1]' index 1 out of bounds)
This commit is contained in:
parent
9e15c4ef38
commit
2334192bff
|
@ -2095,6 +2095,12 @@ void Tokenizer::arraySize()
|
|||
{
|
||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
{
|
||||
if (Token::Match(tok, "%var% [ ] = { %str% }"))
|
||||
{
|
||||
tok->tokAt(4)->deleteThis();
|
||||
tok->tokAt(5)->deleteThis();
|
||||
}
|
||||
|
||||
if (Token::Match(tok, "%var% [ ] = {"))
|
||||
{
|
||||
unsigned int sz = 1;
|
||||
|
|
|
@ -934,6 +934,12 @@ private:
|
|||
ASSERT_EQUALS("; const char str [ 1 ] = { '1' } ; 1 ;", sizeof_(code));
|
||||
}
|
||||
|
||||
{
|
||||
// Ticket #2087
|
||||
const char code[] = "; const char str[] = {\"abc\"}; sizeof(str);";
|
||||
ASSERT_EQUALS("; const char str [ 4 ] = \"abc\" ; 4 ;", sizeof_(code));
|
||||
}
|
||||
|
||||
// ticket #716 - sizeof string
|
||||
{
|
||||
std::ostringstream expected;
|
||||
|
|
Loading…
Reference in New Issue