diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index c285ce32aea7..2d2f02c7ed90 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -14905,6 +14905,7 @@ OMPClause *Sema::ActOnOpenMPNovariantsClause(Expr *Condition, if (CaptureRegion != OMPD_unknown && !CurContext->isDependentContext()) { ValExpr = MakeFullExpr(ValExpr).get(); llvm::MapVector Captures; + ValExpr = tryBuildCapture(*this, ValExpr, Captures).get(); HelperValStmt = buildPreInits(Context, Captures); } } diff --git a/clang/test/OpenMP/dispatch_ast_print.cpp b/clang/test/OpenMP/dispatch_ast_print.cpp index e44c48946bb7..11c0ed82fa90 100644 --- a/clang/test/OpenMP/dispatch_ast_print.cpp +++ b/clang/test/OpenMP/dispatch_ast_print.cpp @@ -56,6 +56,9 @@ void test_one() //DUMP: OMPDependClause //DUMP: OMPNowaitClause //DUMP: OMPNovariantsClause + //DUMP: DeclRefExpr {{.*}} 'bool' lvalue OMPCapturedExpr + //DUMP: OMPNocontextClause + //DUMP: DeclRefExpr {{.*}} 'bool' lvalue OMPCapturedExpr #pragma omp dispatch depend(in:var) nowait novariants(aaa > 5) nocontext(bbb > 5) foo(aaa, &bbb); @@ -66,6 +69,9 @@ void test_one() //DUMP: OMPDeviceClause //DUMP: OMPIs_device_ptrClause //DUMP: OMPNovariantsClause + //DUMP: DeclRefExpr {{.*}} 'bool' lvalue OMPCapturedExpr + //DUMP: OMPNocontextClause + //DUMP: DeclRefExpr {{.*}} 'bool' lvalue OMPCapturedExpr #pragma omp dispatch device(dev) is_device_ptr(dp) novariants(dev > 10) nocontext(dev > 5) foo(aaa, dp);