AST: fix handling of sizeof. ticket #6515

This commit is contained in:
Daniel Marjamäki 2015-02-18 19:56:13 +01:00
parent fd4d4bba33
commit e251a99817
2 changed files with 6 additions and 0 deletions

View File

@ -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();

View File

@ -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;"));