| 4027 | } |
| 4028 | |
| 4029 | static Token *skipTernaryOp(Token *tok) |
| 4030 | { |
| 4031 | int colonLevel = 1; |
| 4032 | while (nullptr != (tok = tok->next())) { |
| 4033 | if (tok->str() == "?") { |
| 4034 | ++colonLevel; |
| 4035 | } else if (tok->str() == ":") { |
| 4036 | --colonLevel; |
| 4037 | if (colonLevel == 0) { |
| 4038 | tok = tok->next(); |
| 4039 | break; |
| 4040 | } |
| 4041 | } |
| 4042 | if (tok->link() && Token::Match(tok, "[(<]")) |
| 4043 | tok = tok->link(); |
| 4044 | else if (Token::Match(tok->next(), "[{};)]")) |
| 4045 | break; |
| 4046 | } |
| 4047 | if (colonLevel > 0) // Ticket #5214: Make sure the ':' matches the proper '?' |
| 4048 | return nullptr; |
| 4049 | return tok; |
| 4050 | } |
| 4051 | |
| 4052 | // Skips until the colon at the end of the case label, the argument must point to the "case" token. |
| 4053 | // In case of success returns the colon token. |
no test coverage detected