parent
e5a22e3436
commit
103ff907b6
|
@ -934,10 +934,15 @@ static void compileScope(Token *&tok, AST_state& state)
|
|||
static bool isPrefixUnary(const Token* tok, bool cpp)
|
||||
{
|
||||
if (!tok->previous()
|
||||
|| ((Token::Match(tok->previous(), "(|[|{|%op%|;|}|?|:|,|.|return|::") || (cpp && tok->strAt(-1) == "throw"))
|
||||
|| ((Token::Match(tok->previous(), "(|[|{|%op%|;|?|:|,|.|return|::") || (cpp && tok->strAt(-1) == "throw"))
|
||||
&& (tok->previous()->tokType() != Token::eIncDecOp || tok->tokType() == Token::eIncDecOp)))
|
||||
return true;
|
||||
|
||||
if (tok->previous()->str() == "}") {
|
||||
const Token* parent = tok->linkAt(-1)->tokAt(-1);
|
||||
return !Token::Match(parent, "%type%") || parent->isKeyword();
|
||||
}
|
||||
|
||||
if (tok->str() == "*" && tok->previous()->tokType() == Token::eIncDecOp && isPrefixUnary(tok->previous(), cpp))
|
||||
return true;
|
||||
|
||||
|
|
|
@ -6428,6 +6428,9 @@ private:
|
|||
ASSERT_EQUALS("ab4<<c--+1:?", testAst("a ? (b << 4) + --c : 1"));
|
||||
ASSERT_EQUALS("ab4<<c--+1:?", testAst("a ? (b << 4) + c-- : 1"));
|
||||
ASSERT_EQUALS("ai[i= i--", testAst("a[i]=i; --i;"));
|
||||
|
||||
ASSERT_EQUALS("fint0{1&(", testAst("f(int{ 0 } & 1);")); // #11572
|
||||
ASSERT_EQUALS("int0{1&return", testAst("int g() { return int{ 0 } & 1; }"));
|
||||
}
|
||||
|
||||
void astfunction() { // function calls
|
||||
|
|
Loading…
Reference in New Issue