summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorKelvin Li <kkwli0@gmail.com>2016-07-18 22:49:16 +0000
committerKelvin Li <kkwli0@gmail.com>2016-07-18 22:49:16 +0000
commit9f645ae63b18be693987b6cc9a764aafc7ece409 (patch)
tree63083b73448baeb638678549b7b11ac5aab039c1 /clang/lib
parentcb2ba5a5a7f2667f7da016b00f9408ae0fccb3f8 (diff)
downloadbcm5719-llvm-9f645ae63b18be693987b6cc9a764aafc7ece409.tar.gz
bcm5719-llvm-9f645ae63b18be693987b6cc9a764aafc7ece409.zip
[OpenMP] Fix incorrect diagnostics in map clause
Having the following code pattern will result in incorrect diagnostic int main() { int arr[10]; #pragma omp target data map(arr[:]) #pragma omp target map(arr) {} } t.cpp:4:24: error: original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage #pragma omp target map(arr) ^~~ t.cpp:3:29: note: used here #pragma omp target data map(arr[:]) ^~~~~~ 1 error generated. Patch by David S. Differential Revision: https://reviews.llvm.org/D22075 llvm-svn: 275926
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 3c8554893b4..1efdcfc6386 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -10680,6 +10680,25 @@ static bool CheckMapConflicts(
if (CI->getAssociatedDeclaration() != SI->getAssociatedDeclaration())
break;
}
+ // Check if the extra components of the expressions in the enclosing
+ // data environment are redundant for the current base declaration.
+ // If they are, the maps completely overlap, which is legal.
+ for (; SI != SE; ++SI) {
+ QualType Type;
+ if (auto *ASE =
+ dyn_cast<ArraySubscriptExpr>(SI->getAssociatedExpression())) {
+ Type = ASE->getBase()->IgnoreParenImpCasts()->getType();
+ } else if (auto *OASE =
+ dyn_cast<OMPArraySectionExpr>(SI->getAssociatedExpression())) {
+ auto *E = OASE->getBase()->IgnoreParenImpCasts();
+ Type =
+ OMPArraySectionExpr::getBaseOriginalType(E).getCanonicalType();
+ }
+ if (Type.isNull() || Type->isAnyPointerType() ||
+ CheckArrayExpressionDoesNotReferToWholeSize(
+ SemaRef, SI->getAssociatedExpression(), Type))
+ break;
+ }
// OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, p.4]
// List items of map clauses in the same construct must not share
OpenPOWER on IntegriCloud