[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
Fri Jun 4 07:35:08 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG827b5c21545a: [OPENMP]Fix PR49790: Constexpr values not handled in `omp declare mapper`… (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103642/new/

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.349869.patch
Type: text/x-patch
Size: 1677 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210604/940f7843/attachment.bin>


More information about the cfe-commits mailing list