Oleksandr T. bb6d2bea64
[Clang] fix confusing diagnostics for lambdas with init-captures inside braced initializers (#166180)
Fixes #163498

---

This PR addresses the issue of confusing diagnostics for lambdas with
init-captures appearing inside braced initializers.

Cases such as:

```cpp
S s{[a(42), &] {}};
```

were misparsed as C99 array designators, producing unrelated
diagnostics, such as `use of undeclared identifier 'a'`, and `expected
']'`

---


bb9bd5f263/clang/lib/Parse/ParseInit.cpp (L470)


bb9bd5f263/clang/lib/Parse/ParseInit.cpp (L74)


bb9bd5f263/clang/include/clang/Parse/Parser.h (L4652-L4655)


24c22b7de6/clang/lib/Parse/ParseExprCXX.cpp (L871-L879)

The tentative parser now returns `Incomplete` for partially valid lambda
introducers, preserving the `lambda` interpretation and allowing the
proper diagnostic to be issued later.

---

Clang now correctly recognizes such constructs as malformed lambda
introducers and emits the expected diagnostic — for example,
“capture-default must be first” — consistent with direct initialization
cases such as:

```cpp
S s([a(42), &] {});
```
2025-11-06 22:55:36 +02:00
..
2024-05-21 15:01:13 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00
2023-08-28 12:13:42 -04:00