[OPENMP]Fix PR43771: Do not capture contexprs variables.
If the variable is a constexpr variable, it should not be captured in the OpenMP region.
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index c7e0d2a..8b1fca8 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -1894,6 +1894,11 @@
assert(LangOpts.OpenMP && "OpenMP is not allowed");
D = getCanonicalDecl(D);
+ auto *VD = dyn_cast<VarDecl>(D);
+ // Do not capture constexpr variables.
+ if (VD && VD->isConstexpr())
+ return nullptr;
+
// If we want to determine whether the variable should be captured from the
// perspective of the current capturing scope, and we've already left all the
// capturing scopes of the top directive on the stack, check from the
@@ -1904,7 +1909,6 @@
// If we are attempting to capture a global variable in a directive with
// 'target' we return true so that this global is also mapped to the device.
//
- auto *VD = dyn_cast<VarDecl>(D);
if (VD && !VD->hasLocalStorage() &&
(getCurCapturedRegion() || getCurBlock() || getCurLambda())) {
if (isInOpenMPDeclareTargetContext()) {