[PATCH] D103642: [OPENMP]Fix PR49790: Constexpr values not handled in `omp declare mapper` clause.
Alexey Bataev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 3 12:14:40 PDT 2021
ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: guansong, yaxunl.
ABataev requested review of this revision.
Herald added a project: clang.
Patch allows using of constexpr vars evaluatable to constant calue to be
used in declare mapper construct.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D103642
Files:
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/declare_mapper_ast_print.cpp
Index: clang/test/OpenMP/declare_mapper_ast_print.cpp
===================================================================
--- clang/test/OpenMP/declare_mapper_ast_print.cpp
+++ clang/test/OpenMP/declare_mapper_ast_print.cpp
@@ -56,8 +56,9 @@
// 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){{$}}
Index: clang/lib/Sema/SemaOpenMP.cpp
===================================================================
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -19681,8 +19681,13 @@
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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103642.349643.patch
Type: text/x-patch
Size: 1677 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210603/970c3fe8/attachment.bin>
More information about the cfe-commits
mailing list