[clang] [OpenMP] Support capturing structured bindings in OpenMP regions. (PR #190832)
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 1 08:01:44 PDT 2026
================
@@ -23567,6 +23888,20 @@ static void checkMappableExpressionList(
continue;
}
+ // Check for unsupported structured bindings early.
+ if (!NoDiagnose) {
+ if (const auto *DRE = dyn_cast<DeclRefExpr>(SimpleExpr)) {
+ const DecompositionDecl *DD = nullptr;
+ if (const auto *BD = dyn_cast<BindingDecl>(DRE->getDecl())) {
+ DD = cast<DecompositionDecl>(BD->getDecomposedDecl());
+ } else if (const auto *D =
+ dyn_cast<DecompositionDecl>(DRE->getDecl())) {
+ DD = D;
+ }
+ if (DD && !getOriginalVarOrDiagnose(SemaRef, DD, ELoc))
----------------
alexey-bataev wrote:
1. It calls getOriginalVarOrDiagnose for any BindingDecl in a map clause, tuple-like or not. If the tuple-like decomposition's source is itself a plain variable (auto [a,b] = existingPair; map(a)), getOriginalVar() happily returns that variable (non-null) since it's just a DeclRefExpr, so this new check doesn't fire - and MapBaseChecker::VisitDeclRefExpr's "fallback: redirect to DecompositionDecl for ... tuples" branch would then map the whole hidden decomposition object rather than reject it the way test_pair/test_tuple (which only test implicit body use, not map()) expect.
2. No test exercises map() on a tuple-like binding at all - worth adding.
https://github.com/llvm/llvm-project/pull/190832
More information about the cfe-commits
mailing list