diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index a014fa565..3894f5a7c 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -566,16 +566,26 @@ static void compileLogicOr(Token *&tok, std::stack &op) } } -static void compileAssign(Token *&tok, std::stack &op) +static void compileTernaryOp(Token *&tok, std::stack &op) { compileLogicOr(tok,op); while (tok) { - if (tok->str() == "=") { + if (Token::Match(tok, "[?:]")) { compileBinOp(tok, compileLogicOr, op); } else break; } } +static void compileAssign(Token *&tok, std::stack &op) +{ + compileTernaryOp(tok,op); + while (tok) { + if (tok->str() == "=") { + compileBinOp(tok, compileTernaryOp, op); + } else break; + } +} + static void compileComma(Token *&tok, std::stack &op) { compileAssign(tok,op);