summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOpenMP.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2016-01-26 12:20:39 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2016-01-26 12:20:39 +0000
commit1189bd020570f465c02176a609eb5109ab2fe0f8 (patch)
tree31de8e7524e874b0b40d586a4c7cc96c9a436500 /clang/lib/Sema/SemaOpenMP.cpp
parent6f50c29ab2ce332c3dadad1d7b3dc8878ba81485 (diff)
downloadbcm5719-llvm-1189bd020570f465c02176a609eb5109ab2fe0f8.tar.gz
bcm5719-llvm-1189bd020570f465c02176a609eb5109ab2fe0f8.zip
[OPENMP 4.5] Allow arrays in 'reduction' clause.
OpenMP 4.5, alogn with array sections, allows to use variables of array type in reductions. llvm-svn: 258804
Diffstat (limited to 'clang/lib/Sema/SemaOpenMP.cpp')
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp24
1 files changed, 7 insertions, 17 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 6272a6284e6..d9ea8fb0cca 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -7469,7 +7469,7 @@ OMPClause *Sema::ActOnOpenMPReductionClause(
if (DE) {
auto D = DE->getDecl();
VD = cast<VarDecl>(D);
- Type = VD->getType();
+ Type = Context.getBaseElementType(VD->getType());
} else if (ASE) {
Type = ASE->getType();
auto *Base = ASE->getBase()->IgnoreParenImpCasts();
@@ -7511,19 +7511,6 @@ OMPClause *Sema::ActOnOpenMPReductionClause(
diag::err_omp_reduction_incomplete_type))
continue;
// OpenMP [2.14.3.6, reduction clause, Restrictions]
- // Arrays may not appear in a reduction clause.
- if (Type.getNonReferenceType()->isArrayType()) {
- Diag(ELoc, diag::err_omp_reduction_type_array) << Type << ERange;
- if (!ASE && !OASE) {
- bool IsDecl = VD->isThisDeclarationADefinition(Context) ==
- VarDecl::DeclarationOnly;
- Diag(VD->getLocation(),
- IsDecl ? diag::note_previous_decl : diag::note_defined_here)
- << VD;
- }
- continue;
- }
- // OpenMP [2.14.3.6, reduction clause, Restrictions]
// A list item that appears in a reduction clause must not be
// const-qualified.
if (Type.getNonReferenceType().isConstant(Context)) {
@@ -7636,8 +7623,9 @@ OMPClause *Sema::ActOnOpenMPReductionClause(
auto *RHSVD = buildVarDecl(*this, ELoc, Type, VD->getName(),
VD->hasAttrs() ? &VD->getAttrs() : nullptr);
auto PrivateTy = Type;
- if (OASE) {
- // For array sections only:
+ if (OASE ||
+ (DE && VD->getType().getNonReferenceType()->isVariablyModifiedType())) {
+ // For arays/array sections only:
// Create pseudo array type for private copy. The size for this array will
// be generated during codegen.
// For array subscripts or single variables Private Ty is the same as Type
@@ -7646,7 +7634,9 @@ OMPClause *Sema::ActOnOpenMPReductionClause(
Type, new (Context) OpaqueValueExpr(SourceLocation(),
Context.getSizeType(), VK_RValue),
ArrayType::Normal, /*IndexTypeQuals=*/0, SourceRange());
- }
+ } else if (DE &&
+ Context.getAsArrayType(VD->getType().getNonReferenceType()))
+ PrivateTy = VD->getType().getNonReferenceType();
// Private copy.
auto *PrivateVD = buildVarDecl(*this, ELoc, PrivateTy, VD->getName(),
VD->hasAttrs() ? &VD->getAttrs() : nullptr);
OpenPOWER on IntegriCloud