summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2018-05-02 18:44:10 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2018-05-02 18:44:10 +0000
commit354df2eeabaffb6ead755d1808319da43172c40d (patch)
treeee004da64264d4c2e1b2900d658c5d43ae15360f
parentd0b5034b8a9da4401d0cce80338ef069f38ca487 (diff)
downloadbcm5719-llvm-354df2eeabaffb6ead755d1808319da43172c40d.tar.gz
bcm5719-llvm-354df2eeabaffb6ead755d1808319da43172c40d.zip
[OPENMP] Analyze the type of the mapped entity instead of its base.
If the mapped entity is a data member, we erroneously checked the type of its base rather than the type of the mapped entity itself. llvm-svn: 331385
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp9
-rw-r--r--clang/test/OpenMP/target_map_messages.cpp10
2 files changed, 17 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 832f03b9394..292cc6710aa 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -12305,7 +12305,14 @@ checkMappableExpressionList(Sema &SemaRef, DSAStackTy *DSAS,
// OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, C++, p.1]
// If the type of a list item is a reference to a type T then the type will
// be considered to be T for all purposes of this clause.
- QualType Type = CurDeclaration->getType().getNonReferenceType();
+ auto I = llvm::find_if(
+ CurComponents,
+ [](const OMPClauseMappableExprCommon::MappableComponent &MC) {
+ return MC.getAssociatedDeclaration();
+ });
+ assert(I != CurComponents.end() && "Null decl on map clause.");
+ QualType Type =
+ I->getAssociatedDeclaration()->getType().getNonReferenceType();
// OpenMP 4.5 [2.10.5, target update Construct, Restrictions, p.4]
// A list item in a to or from clause must have a mappable type.
diff --git a/clang/test/OpenMP/target_map_messages.cpp b/clang/test/OpenMP/target_map_messages.cpp
index 17f3ba5bace..03a81ee575b 100644
--- a/clang/test/OpenMP/target_map_messages.cpp
+++ b/clang/test/OpenMP/target_map_messages.cpp
@@ -19,6 +19,13 @@ void foo(int arg) {
{}
}
#else
+
+struct SREF {
+ int &a;
+ int b;
+ SREF(int &a) : a(a) {}
+};
+
template <typename T, int I>
struct SA {
static int ss;
@@ -31,13 +38,14 @@ struct SA {
T *f;
int bf : 20;
void func(int arg) {
+ SREF sref(arg);
#pragma omp target
{
a = 0.0;
func(arg);
bf = 20;
}
- #pragma omp target map(arg,a,d)
+ #pragma omp target map(arg,a,d,sref.b)
{}
#pragma omp target map(arg[2:2],a,d) // expected-error {{subscripted value is not an array or pointer}}
{}
OpenPOWER on IntegriCloud