Daniel Marjamäki f5fe5ca2dd
9768: Fix ast with throw in the middle of return (#2678)
* 9768: Fix ast with throw in the middle of return

```
int f(bool x)
{
    return x ? 0 : throw 0;
}
```

The `throw` part was not included in the ast, leading to an invalid
ternary operator.

* 8526: Fix ast construction for ternary operator

This tries to decide a bit more properly when ':' can be part of a
ternary operator. More precisely, there are some times when we want to
delay the construction of the ast for ':', so that it is place
accordingly to the matching '?'.

Typically, this fixes an issue with
`return val < 0 ? throw 1 : val;`,
where the ast for ':' would be constructed during as part of the
`throw`, and the ast for `?` would be invalid.

This patch is a bit of a hardcode, stating that we don't expect ':'
inside a throw, unless there is a complete ternary operator in there
(there can't be a range based for loop, a case in a switch). When we
reach ':', we know we are and the end of the `throw`.
2020-06-15 10:36:02 +02:00
..
2019-06-29 07:49:14 +02:00
2019-06-29 07:49:14 +02:00
2020-06-13 16:37:12 +02:00
2020-05-10 11:16:32 +02:00
2019-02-09 07:24:06 +01:00
2020-05-10 11:16:32 +02:00
2020-05-10 11:16:32 +02:00
2020-05-10 11:16:32 +02:00
2020-06-13 16:37:12 +02:00
2020-06-13 16:37:12 +02:00
2019-02-09 07:24:06 +01:00
2020-05-10 11:16:32 +02:00
2020-05-10 11:16:32 +02:00
2020-06-13 16:37:12 +02:00
2020-05-10 11:16:32 +02:00
2019-02-09 07:24:06 +01:00
2020-05-10 11:16:32 +02:00
2020-05-10 11:16:32 +02:00
2020-05-10 11:16:32 +02:00
2019-06-29 07:49:14 +02:00
2020-06-13 16:37:12 +02:00
2020-06-13 16:37:12 +02:00
2020-05-23 07:16:49 +02:00
2019-02-09 07:24:06 +01:00
2019-02-09 07:24:06 +01:00
2020-05-10 11:16:32 +02:00
2020-05-10 11:16:32 +02:00
2020-06-13 16:37:12 +02:00
2020-05-10 11:16:32 +02:00
2020-05-10 11:16:32 +02:00
2020-06-13 16:37:12 +02:00
2019-03-16 09:17:50 +01:00
2020-05-25 16:02:34 +02:00