[all-commits] [llvm/llvm-project] bb6d2b: [Clang] fix confusing diagnostics for lambdas with...
Oleksandr T. via All-commits
all-commits at lists.llvm.org
Thu Nov 6 12:55:57 PST 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: bb6d2bea6495b044a0773598916eba801f8d38fc
https://github.com/llvm/llvm-project/commit/bb6d2bea6495b044a0773598916eba801f8d38fc
Author: Oleksandr T. <oleksandr.tarasiuk at outlook.com>
Date: 2025-11-06 (Thu, 06 Nov 2025)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/lib/Parse/ParseExprCXX.cpp
M clang/test/Parser/lambda-misplaced-capture-default.cpp
Log Message:
-----------
[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
']'`
---
https://github.com/llvm/llvm-project/blob/bb9bd5f263226840194b28457ddf9861986db51f/clang/lib/Parse/ParseInit.cpp#L470
https://github.com/llvm/llvm-project/blob/bb9bd5f263226840194b28457ddf9861986db51f/clang/lib/Parse/ParseInit.cpp#L74
https://github.com/llvm/llvm-project/blob/bb9bd5f263226840194b28457ddf9861986db51f/clang/include/clang/Parse/Parser.h#L4652-L4655
https://github.com/llvm/llvm-project/blob/24c22b7de620669aed9da28de323309c44a58244/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), &] {});
```
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list