From e251a99817e43d2d99616f188453e24396855b1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 18 Feb 2015 19:56:13 +0100 Subject: [PATCH] AST: fix handling of sizeof. ticket #6515 --- lib/tokenlist.cpp | 3 +++ test/testtokenize.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 0c3d73ea4..67c06c584 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -521,6 +521,9 @@ static void compileTerm(Token *&tok, AST_state& state) if (tok->str() == "return") { compileUnaryOp(tok, state, compileExpression); state.op.pop(); + } else if (Token::Match(tok, "sizeof !!(")) { + compileUnaryOp(tok, state, compileExpression); + state.op.pop(); } else if (!state.cpp || !Token::Match(tok, "new|delete %name%|*|&|::|(|[")) { while (tok->next() && tok->next()->isName()) tok = tok->next(); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 3542cf73c..671cbd6c7 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -8443,6 +8443,9 @@ private: ASSERT_EQUALS("a-1+", testAst("-a+1")); ASSERT_EQUALS("ab++-c-", testAst("a-b++-c")); + // sizeof + ASSERT_EQUALS("ab.sizeof", testAst("sizeof a.b")); + // assignment operators ASSERT_EQUALS("ab>>=", testAst("a>>=b;")); ASSERT_EQUALS("ab<<=", testAst("a<<=b;"));