Fix handling of `sizeof &var` (#1498)
Fixes https://trac.cppcheck.net/ticket/8870
This commit is contained in:
parent
86f984020b
commit
cad4e4ab20
|
@ -3340,7 +3340,7 @@ void Tokenizer::sizeofAddParentheses()
|
|||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||
if (!Token::Match(tok, "sizeof !!("))
|
||||
continue;
|
||||
if (tok->next()->isLiteral() || Token::Match(tok->next(), "%name%|*|~|!")) {
|
||||
if (tok->next()->isLiteral() || Token::Match(tok->next(), "%name%|*|~|!|&")) {
|
||||
Token *endToken = tok->next();
|
||||
while (Token::simpleMatch(endToken, "* *"))
|
||||
endToken = endToken->next();
|
||||
|
|
|
@ -8662,6 +8662,7 @@ private:
|
|||
ASSERT_EQUALS("sizeof ( a . b ) + 3 ;", tokenizeAndStringify("sizeof a.b+3;"));
|
||||
ASSERT_EQUALS("sizeof ( a [ 2 ] . b ) + 3 ;", tokenizeAndStringify("sizeof a[2].b+3;"));
|
||||
ASSERT_EQUALS("f ( 0 , sizeof ( ptr . bar ) ) ;", tokenizeAndStringify("f(0, sizeof ptr->bar );"));
|
||||
ASSERT_EQUALS("sizeof ( a ) > sizeof ( & main ) ;", tokenizeAndStringify("sizeof a > sizeof &main;"));
|
||||
}
|
||||
|
||||
void findGarbageCode() { // Make sure the Tokenizer::findGarbageCode() does not have FPs
|
||||
|
|
Loading…
Reference in New Issue