summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOpenMP.cpp
diff options
context:
space:
mode:
authorMichael Kruse <llvm@meinersbur.de>2019-09-26 22:53:01 +0000
committerMichael Kruse <llvm@meinersbur.de>2019-09-26 22:53:01 +0000
commit945249b5a99d44f494e084a7c1ac5da810f16f6a (patch)
tree8a4ec7c23970b6ab8780f6f72d1e13768b34f788 /clang/lib/Sema/SemaOpenMP.cpp
parentbf322b7cdd608630a42fd65687b74051601c357d (diff)
downloadbcm5719-llvm-945249b5a99d44f494e084a7c1ac5da810f16f6a.tar.gz
bcm5719-llvm-945249b5a99d44f494e084a7c1ac5da810f16f6a.zip
[OpenMP 5.0] Fix user-defined mapper lookup in sema
This patches fixes the case when a user-defined mapper is attached to the elements of an array, and to report error when a mapper is used for types other than struct, class, and union. Patch by Lingda Li <lildmh@gmail.com> Differential Revision: https://reviews.llvm.org/D67978 llvm-svn: 373023
Diffstat (limited to 'clang/lib/Sema/SemaOpenMP.cpp')
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 17586c90bd1..6e2a34447a4 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -14754,6 +14754,11 @@ static ExprResult buildUserDefinedMapperRef(Sema &SemaRef, Scope *S,
Expr *UnresolvedMapper) {
if (MapperIdScopeSpec.isInvalid())
return ExprError();
+ // Get the actual type for the array type.
+ if (Type->isArrayType()) {
+ assert(Type->getAsArrayTypeUnsafe() && "Expect to get a valid array type");
+ Type = Type->getAsArrayTypeUnsafe()->getElementType().getCanonicalType();
+ }
// Find all user-defined mappers with the given MapperId.
SmallVector<UnresolvedSet<8>, 4> Lookups;
LookupResult Lookup(SemaRef, MapperId, Sema::LookupOMPMapperName);
@@ -14800,11 +14805,14 @@ static ExprResult buildUserDefinedMapperRef(Sema &SemaRef, Scope *S,
MapperIdScopeSpec.getWithLocInContext(SemaRef.Context), MapperId,
/*ADL=*/false, /*Overloaded=*/true, URS.begin(), URS.end());
}
+ SourceLocation Loc = MapperId.getLoc();
// [OpenMP 5.0], 2.19.7.3 declare mapper Directive, Restrictions
// The type must be of struct, union or class type in C and C++
- if (!Type->isStructureOrClassType() && !Type->isUnionType())
- return ExprEmpty();
- SourceLocation Loc = MapperId.getLoc();
+ if (!Type->isStructureOrClassType() && !Type->isUnionType() &&
+ (MapperIdScopeSpec.isSet() || MapperId.getAsString() != "default")) {
+ SemaRef.Diag(Loc, diag::err_omp_mapper_wrong_type);
+ return ExprError();
+ }
// Perform argument dependent lookup.
if (SemaRef.getLangOpts().CPlusPlus && !MapperIdScopeSpec.isSet())
argumentDependentLookup(SemaRef, MapperId, Loc, Type, Lookups);
OpenPOWER on IntegriCloud