You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Sema] Fix inconsistent shadow warnings for lambda capture of structured bindings
Lambda captures that shadow structured bindings were incorrectly classified
as regular shadow warnings (shown with -Wshadow) while regular parameter
captures were classified as uncaptured-local warnings (shown only with
-Wshadow-all). This created inconsistent behavior between semantically
equivalent code patterns.
This change extends the existing lambda capture classification logic to
handle BindingDecl consistently with VarDecl:
- Lambda init captures of structured bindings now show as uncaptured-local
- Regular variable declarations inside lambda bodies still show as shadow
- All existing shadow warning functionality is preserved
The fix ensures consistent behavior between:
void func(std::pair<int,int> val) { [val = val](){}; } // no -Wshadow, warns with -Wshadow-all
void func(std::pair<int,int> val) { auto [a,b] = val; [a = a](){}; } // no -Wshadow, warns with -Wshadow-all
Previously the structured binding case incorrectly produced warnings with
basic -Wshadow, preventing structured bindings from being used in lambda
captures consistently with regular parameters.
0 commit comments