[clang] [Sema] Add lambda decltype((x)) semantics to blocks (#207355) (PR #207583)

Akira Hatanaka via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 11 10:47:30 PDT 2026


================
@@ -10055,7 +10055,11 @@ QualType Sema::getDecltypeForExpr(Expr *E) {
   //   access to a corresponding data member of the closure type that
   //   would have been declared if x were an odr-use of the denoted
   //   entity.
-  if (getCurLambda() && isa<ParenExpr>(IDExpr)) {
+
+  // decltype result for blocks should be the same as decltype result in 
+  // lambdas because blocks capture variables the same as lambdas do
+  // https://github.com/llvm/llvm-project/issues/207355#issuecomment-4877181419
+  if (isa<ParenExpr>(IDExpr)) {
----------------
ahatanak wrote:

The guard changed from `getCurLambda() && isa<ParenExpr>(IDExpr)` to just `isa<ParenExpr>(IDExpr)`, not to something block specific. That means any capturing contexts, including OpenMP captured regions, etc., go through this code now too.

Should we update the description to say the fix generalizes the rule to capturing contexts broadly, not just blocks specifically? It looks like block is the only context where this actually changes behavior, but please verify that yourself.

https://github.com/llvm/llvm-project/pull/207583


More information about the cfe-commits mailing list