diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2019-12-20 11:04:57 -0500 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2019-12-24 12:22:05 -0500 |
commit | 93dc40dddde40cff2f54b68c66abb00927cdbcea (patch) | |
tree | b63973cdc9636d337fb7dee48d9ec1fd4b633b34 /clang/lib/Sema/SemaOpenMP.cpp | |
parent | 0d47399167eee87711f5c93a3f36801c7b6a6774 (diff) | |
download | bcm5719-llvm-93dc40dddde40cff2f54b68c66abb00927cdbcea.tar.gz bcm5719-llvm-93dc40dddde40cff2f54b68c66abb00927cdbcea.zip |
[OPENMP50]Basic support for conditional lastprivate.
Added parsing/sema checks for conditional lastprivates.
Diffstat (limited to 'clang/lib/Sema/SemaOpenMP.cpp')
-rw-r--r-- | clang/lib/Sema/SemaOpenMP.cpp | 61 |
1 files changed, 44 insertions, 17 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 7365fda62be..404ca5028de 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -12402,11 +12402,10 @@ OMPClause *Sema::ActOnOpenMPVarListClause( OpenMPClauseKind Kind, ArrayRef<Expr *> VarList, Expr *TailExpr, const OMPVarListLocTy &Locs, SourceLocation ColonLoc, CXXScopeSpec &ReductionOrMapperIdScopeSpec, - DeclarationNameInfo &ReductionOrMapperId, OpenMPDependClauseKind DepKind, - OpenMPLinearClauseKind LinKind, + DeclarationNameInfo &ReductionOrMapperId, int ExtraModifier, ArrayRef<OpenMPMapModifierKind> MapTypeModifiers, - ArrayRef<SourceLocation> MapTypeModifiersLoc, OpenMPMapClauseKind MapType, - bool IsMapTypeImplicit, SourceLocation DepLinMapLoc) { + ArrayRef<SourceLocation> MapTypeModifiersLoc, bool IsMapTypeImplicit, + SourceLocation DepLinMapLastLoc) { SourceLocation StartLoc = Locs.StartLoc; SourceLocation LParenLoc = Locs.LParenLoc; SourceLocation EndLoc = Locs.EndLoc; @@ -12419,7 +12418,9 @@ OMPClause *Sema::ActOnOpenMPVarListClause( Res = ActOnOpenMPFirstprivateClause(VarList, StartLoc, LParenLoc, EndLoc); break; case OMPC_lastprivate: - Res = ActOnOpenMPLastprivateClause(VarList, StartLoc, LParenLoc, EndLoc); + Res = ActOnOpenMPLastprivateClause( + VarList, static_cast<OpenMPLastprivateModifier>(ExtraModifier), + DepLinMapLastLoc, ColonLoc, StartLoc, LParenLoc, EndLoc); break; case OMPC_shared: Res = ActOnOpenMPSharedClause(VarList, StartLoc, LParenLoc, EndLoc); @@ -12440,8 +12441,10 @@ OMPClause *Sema::ActOnOpenMPVarListClause( ReductionOrMapperId); break; case OMPC_linear: - Res = ActOnOpenMPLinearClause(VarList, TailExpr, StartLoc, LParenLoc, - LinKind, DepLinMapLoc, ColonLoc, EndLoc); + Res = ActOnOpenMPLinearClause( + VarList, TailExpr, StartLoc, LParenLoc, + static_cast<OpenMPLinearClauseKind>(ExtraModifier), DepLinMapLastLoc, + ColonLoc, EndLoc); break; case OMPC_aligned: Res = ActOnOpenMPAlignedClause(VarList, TailExpr, StartLoc, LParenLoc, @@ -12457,14 +12460,15 @@ OMPClause *Sema::ActOnOpenMPVarListClause( Res = ActOnOpenMPFlushClause(VarList, StartLoc, LParenLoc, EndLoc); break; case OMPC_depend: - Res = ActOnOpenMPDependClause(DepKind, DepLinMapLoc, ColonLoc, VarList, - StartLoc, LParenLoc, EndLoc); + Res = ActOnOpenMPDependClause( + static_cast<OpenMPDependClauseKind>(ExtraModifier), DepLinMapLastLoc, + ColonLoc, VarList, StartLoc, LParenLoc, EndLoc); break; case OMPC_map: - Res = ActOnOpenMPMapClause(MapTypeModifiers, MapTypeModifiersLoc, - ReductionOrMapperIdScopeSpec, - ReductionOrMapperId, MapType, IsMapTypeImplicit, - DepLinMapLoc, ColonLoc, VarList, Locs); + Res = ActOnOpenMPMapClause( + MapTypeModifiers, MapTypeModifiersLoc, ReductionOrMapperIdScopeSpec, + ReductionOrMapperId, static_cast<OpenMPMapClauseKind>(ExtraModifier), + IsMapTypeImplicit, DepLinMapLastLoc, ColonLoc, VarList, Locs); break; case OMPC_to: Res = ActOnOpenMPToClause(VarList, ReductionOrMapperIdScopeSpec, @@ -12990,10 +12994,19 @@ OMPClause *Sema::ActOnOpenMPFirstprivateClause(ArrayRef<Expr *> VarList, buildPreInits(Context, ExprCaptures)); } -OMPClause *Sema::ActOnOpenMPLastprivateClause(ArrayRef<Expr *> VarList, - SourceLocation StartLoc, - SourceLocation LParenLoc, - SourceLocation EndLoc) { +OMPClause *Sema::ActOnOpenMPLastprivateClause( + ArrayRef<Expr *> VarList, OpenMPLastprivateModifier LPKind, + SourceLocation LPKindLoc, SourceLocation ColonLoc, SourceLocation StartLoc, + SourceLocation LParenLoc, SourceLocation EndLoc) { + if (LPKind == OMPC_LASTPRIVATE_unknown && LPKindLoc.isValid()) { + assert(ColonLoc.isValid() && "Colon location must be valid."); + Diag(LPKindLoc, diag::err_omp_unexpected_clause_value) + << getListOfPossibleValues(OMPC_lastprivate, /*First=*/0, + /*Last=*/OMPC_LASTPRIVATE_unknown) + << getOpenMPClauseName(OMPC_lastprivate); + return nullptr; + } + SmallVector<Expr *, 8> Vars; SmallVector<Expr *, 8> SrcExprs; SmallVector<Expr *, 8> DstExprs; @@ -13039,6 +13052,19 @@ OMPClause *Sema::ActOnOpenMPLastprivateClause(ArrayRef<Expr *> VarList, if (rejectConstNotMutableType(*this, D, Type, OMPC_lastprivate, ELoc)) continue; + // OpenMP 5.0 [2.19.4.5 lastprivate Clause, Restrictions] + // A list item that appears in a lastprivate clause with the conditional + // modifier must be a scalar variable. + if (LPKind == OMPC_LASTPRIVATE_conditional && !Type->isScalarType()) { + Diag(ELoc, diag::err_omp_lastprivate_conditional_non_scalar); + bool IsDecl = !VD || VD->isThisDeclarationADefinition(Context) == + VarDecl::DeclarationOnly; + Diag(D->getLocation(), + IsDecl ? diag::note_previous_decl : diag::note_defined_here) + << D; + continue; + } + OpenMPDirectiveKind CurrDir = DSAStack->getCurrentDirective(); // OpenMP [2.14.1.1, Data-sharing Attribute Rules for Variables Referenced // in a Construct] @@ -13147,6 +13173,7 @@ OMPClause *Sema::ActOnOpenMPLastprivateClause(ArrayRef<Expr *> VarList, return OMPLastprivateClause::Create(Context, StartLoc, LParenLoc, EndLoc, Vars, SrcExprs, DstExprs, AssignmentOps, + LPKind, LPKindLoc, ColonLoc, buildPreInits(Context, ExprCaptures), buildPostUpdate(*this, ExprPostUpdates)); } |