@@ -17305,6 +17305,43 @@ OMPClause *SemaOpenMP::ActOnOpenMPSimpleClause(
1730517305 return Res;
1730617306}
1730717307
17308+ static std::pair<OpenMPDefaultmapClauseModifier, OpenMPDefaultmapClauseKind>
17309+ getDefaultmapModifierAndKind(llvm::omp::DefaultKind M,
17310+ OpenMPDefaultClauseVariableCategory VCKind) {
17311+ OpenMPDefaultmapClauseModifier DefMapMod;
17312+ OpenMPDefaultmapClauseKind DefMapKind;
17313+ switch (M) {
17314+ case OMP_DEFAULT_none:
17315+ DefMapMod = OMPC_DEFAULTMAP_MODIFIER_none;
17316+ break;
17317+ case OMP_DEFAULT_firstprivate:
17318+ DefMapMod = OMPC_DEFAULTMAP_MODIFIER_firstprivate;
17319+ break;
17320+ case OMP_DEFAULT_private:
17321+ DefMapMod = OMPC_DEFAULTMAP_MODIFIER_private;
17322+ break;
17323+ default:
17324+ llvm_unreachable("unexpected DSA in OpenMP default clause");
17325+ }
17326+ switch (VCKind) {
17327+ case OMPC_DEFAULT_VC_aggregate:
17328+ DefMapKind = OMPC_DEFAULTMAP_aggregate;
17329+ break;
17330+ case OMPC_DEFAULT_VC_pointer:
17331+ DefMapKind = OMPC_DEFAULTMAP_pointer;
17332+ break;
17333+ case OMPC_DEFAULT_VC_scalar:
17334+ DefMapKind = OMPC_DEFAULTMAP_scalar;
17335+ break;
17336+ case OMPC_DEFAULT_VC_all:
17337+ DefMapKind = OMPC_DEFAULTMAP_all;
17338+ break;
17339+ default:
17340+ llvm_unreachable("unexpected variable category in OpenMP default clause");
17341+ }
17342+ return std::make_pair(DefMapMod, DefMapKind);
17343+ }
17344+
1730817345OMPClause *SemaOpenMP::ActOnOpenMPDefaultClause(
1730917346 llvm::omp::DefaultKind M, SourceLocation MLoc,
1731017347 OpenMPDefaultClauseVariableCategory VCKind, SourceLocation VCKindLoc,
@@ -17317,21 +17354,40 @@ OMPClause *SemaOpenMP::ActOnOpenMPDefaultClause(
1731717354 return nullptr;
1731817355 }
1731917356
17320- switch (M) {
17321- case OMP_DEFAULT_none:
17322- DSAStack->setDefaultDSANone(MLoc);
17323- break;
17324- case OMP_DEFAULT_shared:
17325- DSAStack->setDefaultDSAShared(MLoc);
17326- break;
17327- case OMP_DEFAULT_firstprivate:
17328- DSAStack->setDefaultDSAFirstPrivate(MLoc);
17329- break;
17330- case OMP_DEFAULT_private:
17331- DSAStack->setDefaultDSAPrivate(MLoc);
17332- break;
17333- default:
17334- llvm_unreachable("DSA unexpected in OpenMP default clause");
17357+ if (getLangOpts().OpenMP >= 60 &&
17358+ DSAStack->getCurrentDirective() == OMPD_target) {
17359+ // OpenMP 6.0 (see page 224, lines 3-5) default Clause, Semantics
17360+ // If data-sharing-attribute is shared then the clause has no effect
17361+ // on a target construct; otherwise, its effect on a target construct is
17362+ // equivalent to specifying the defaultmap clause with the same
17363+ // data-sharing-attribute and variable-category.
17364+ if (M != OMP_DEFAULT_shared) {
17365+ auto [DefMapMod, DefMapKind] = getDefaultmapModifierAndKind(M, VCKind);
17366+ if (DefMapKind == OMPC_DEFAULTMAP_all) {
17367+ DSAStack->setDefaultDMAAttr(DefMapMod, OMPC_DEFAULTMAP_aggregate, MLoc);
17368+ DSAStack->setDefaultDMAAttr(DefMapMod, OMPC_DEFAULTMAP_scalar, MLoc);
17369+ DSAStack->setDefaultDMAAttr(DefMapMod, OMPC_DEFAULTMAP_pointer, MLoc);
17370+ } else {
17371+ DSAStack->setDefaultDMAAttr(DefMapMod, DefMapKind, MLoc);
17372+ }
17373+ }
17374+ } else {
17375+ switch (M) {
17376+ case OMP_DEFAULT_none:
17377+ DSAStack->setDefaultDSANone(MLoc);
17378+ break;
17379+ case OMP_DEFAULT_shared:
17380+ DSAStack->setDefaultDSAShared(MLoc);
17381+ break;
17382+ case OMP_DEFAULT_firstprivate:
17383+ DSAStack->setDefaultDSAFirstPrivate(MLoc);
17384+ break;
17385+ case OMP_DEFAULT_private:
17386+ DSAStack->setDefaultDSAPrivate(MLoc);
17387+ break;
17388+ default:
17389+ llvm_unreachable("DSA unexpected in OpenMP default clause");
17390+ }
1733517391 }
1733617392
1733717393 switch (VCKind) {
0 commit comments