diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 9aad928d5..54937388c 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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(); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 199f026d0..759e0a297 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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