Patch allows using of constexpr vars evaluatable to constant calue to be
used in declare mapper construct.
Differential Revision: https://reviews.llvm.org/D103642
bool Sema::isOpenMPDeclareMapperVarDeclAllowed(const VarDecl *VD) const {
assert(LangOpts.OpenMP && "Expected OpenMP mode.");
const Expr *Ref = DSAStack->getDeclareMapperVarRef();
- if (const auto *DRE = cast_or_null<DeclRefExpr>(Ref))
- return VD->getCanonicalDecl() == DRE->getDecl()->getCanonicalDecl();
+ if (const auto *DRE = cast_or_null<DeclRefExpr>(Ref)) {
+ if (VD->getCanonicalDecl() == DRE->getDecl()->getCanonicalDecl())
+ return true;
+ if (VD->isUsableInConstantExpressions(Context))
+ return true;
+ return false;
+ }
return true;
}
// CHECK: #pragma omp declare mapper (id : dat<double>::datin v) map(tofrom: v.in){{$}}
// CHECK: };
-#pragma omp declare mapper(default : N1::vec kk) map(kk.len) map(kk.data[0:2])
-// CHECK: #pragma omp declare mapper (default : N1::vec kk) map(tofrom: kk.len) map(tofrom: kk.data[0:2]){{$}}
+constexpr int N = 2;
+#pragma omp declare mapper(default : N1::vec kk) map(kk.len) map(kk.data[0:N])
+// CHECK: #pragma omp declare mapper (default : N1::vec kk) map(tofrom: kk.len) map(tofrom: kk.data[0:N]){{$}}
#pragma omp declare mapper(dat<double> d) map(to: d.d)
// CHECK: #pragma omp declare mapper (default : dat<double> d) map(to: d.d){{$}}