Loading clang/include/clang/Basic/DiagnosticSemaKinds.td +1 −1 Original line number Diff line number Diff line Loading @@ -9633,7 +9633,7 @@ def err_omp_expected_var_name_member_expr : Error< def err_omp_expected_var_name_member_expr_or_array_item : Error< "expected variable name%select{|, data member of current class}0, array element or array section">; def err_omp_expected_addressable_lvalue_or_array_item : Error< "expected addressable lvalue expression, array element or array section">; "expected addressable lvalue expression, array element or array section%select{| of non 'omp_depend_t' type}0">; def err_omp_expected_named_var_member_or_array_expression: Error< "expected expression containing only member accesses and/or array sections based on named variables">; def err_omp_bit_fields_forbidden_in_clause : Error< Loading clang/include/clang/Basic/OpenMPKinds.def +1 −0 Original line number Diff line number Diff line Loading @@ -384,6 +384,7 @@ OPENMP_DEPEND_KIND(in) OPENMP_DEPEND_KIND(out) OPENMP_DEPEND_KIND(inout) OPENMP_DEPEND_KIND(mutexinoutset) OPENMP_DEPEND_KIND(depobj) OPENMP_DEPEND_KIND(source) OPENMP_DEPEND_KIND(sink) Loading clang/lib/CodeGen/CGOpenMPRuntime.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -5214,6 +5214,7 @@ static RTLDependenceKindTy translateDependencyKind(OpenMPDependClauseKind K) { break; case OMPC_DEPEND_source: case OMPC_DEPEND_sink: case OMPC_DEPEND_depobj: case OMPC_DEPEND_unknown: llvm_unreachable("Unknown task dependence type"); } Loading clang/lib/Parse/ParseOpenMP.cpp +1 −3 Original line number Diff line number Diff line Loading @@ -3198,9 +3198,7 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind, Data.RLoc = Tok.getLocation(); if (!T.consumeClose()) Data.RLoc = T.getCloseLocation(); return (Kind == OMPC_depend && Data.ExtraModifier != OMPC_DEPEND_unknown && Vars.empty()) || (Kind != OMPC_depend && Kind != OMPC_map && Vars.empty()) || return (Kind != OMPC_depend && Kind != OMPC_map && Vars.empty()) || (MustHaveTail && !Data.TailExpr) || InvalidReductionId || IsInvalidMapperModifier; } Loading clang/lib/Sema/SemaOpenMP.cpp +99 −38 Original line number Diff line number Diff line Loading @@ -12247,8 +12247,9 @@ OMPClause *Sema::ActOnOpenMPUpdateClause(OpenMPDependClauseKind Kind, SourceLocation LParenLoc, SourceLocation EndLoc) { if (Kind == OMPC_DEPEND_unknown || Kind == OMPC_DEPEND_source || Kind == OMPC_DEPEND_sink) { unsigned Except[] = {OMPC_DEPEND_source, OMPC_DEPEND_sink}; Kind == OMPC_DEPEND_sink || Kind == OMPC_DEPEND_depobj) { unsigned Except[] = {OMPC_DEPEND_source, OMPC_DEPEND_sink, OMPC_DEPEND_depobj}; Diag(KindKwLoc, diag::err_omp_unexpected_clause_value) << getListOfPossibleValues(OMPC_depend, /*First=*/0, /*Last=*/OMPC_DEPEND_unknown, Except) Loading Loading @@ -15208,13 +15209,15 @@ OMPClause *Sema::ActOnOpenMPFlushClause(ArrayRef<Expr *> VarList, } /// Tries to find omp_depend_t. type. static bool findOMPDependT(Sema &S, SourceLocation Loc, DSAStackTy *Stack) { static bool findOMPDependT(Sema &S, SourceLocation Loc, DSAStackTy *Stack, bool Diagnose = true) { QualType OMPDependT = Stack->getOMPDependT(); if (!OMPDependT.isNull()) return true; IdentifierInfo *II = &S.PP.getIdentifierTable().get("omp_depend_t"); ParsedType PT = S.getTypeName(*II, Loc, S.getCurScope()); if (!PT.getAsOpaquePtr() || PT.get().isNull()) { if (Diagnose) S.Diag(Loc, diag::err_omp_implied_type_not_found) << "omp_depend_t"; return false; } Loading Loading @@ -15264,8 +15267,15 @@ Sema::ActOnOpenMPDependClause(OpenMPDependClauseKind DepKind, if ((DSAStack->getCurrentDirective() != OMPD_ordered || DSAStack->getCurrentDirective() == OMPD_depobj) && (DepKind == OMPC_DEPEND_unknown || DepKind == OMPC_DEPEND_source || DepKind == OMPC_DEPEND_sink)) { unsigned Except[] = {OMPC_DEPEND_source, OMPC_DEPEND_sink}; DepKind == OMPC_DEPEND_sink || ((LangOpts.OpenMP < 50 || DSAStack->getCurrentDirective() == OMPD_depobj) && DepKind == OMPC_DEPEND_depobj))) { SmallVector<unsigned, 3> Except; Except.push_back(OMPC_DEPEND_source); Except.push_back(OMPC_DEPEND_sink); if (LangOpts.OpenMP < 50 || DSAStack->getCurrentDirective() == OMPD_depobj) Except.push_back(OMPC_DEPEND_depobj); Diag(DepLoc, diag::err_omp_unexpected_clause_value) << getListOfPossibleValues(OMPC_depend, /*First=*/0, /*Last=*/OMPC_DEPEND_unknown, Except) Loading Loading @@ -15371,11 +15381,44 @@ Sema::ActOnOpenMPDependClause(OpenMPDependClauseKind DepKind, continue; } OpsOffs.emplace_back(RHS, OOK); } else { bool OMPDependTFound = LangOpts.OpenMP >= 50; if (OMPDependTFound) OMPDependTFound = findOMPDependT(*this, StartLoc, DSAStack, DepKind == OMPC_DEPEND_depobj); if (DepKind == OMPC_DEPEND_depobj) { // OpenMP 5.0, 2.17.11 depend Clause, Restrictions, C/C++ // List items used in depend clauses with the depobj dependence type // must be expressions of the omp_depend_t type. if (!RefExpr->isValueDependent() && !RefExpr->isTypeDependent() && !RefExpr->isInstantiationDependent() && !RefExpr->containsUnexpandedParameterPack() && (OMPDependTFound && !Context.hasSameUnqualifiedType(DSAStack->getOMPDependT(), RefExpr->getType()))) { Diag(ELoc, diag::err_omp_expected_omp_depend_t_lvalue) << 0 << RefExpr->getType() << RefExpr->getSourceRange(); continue; } if (!RefExpr->isLValue()) { Diag(ELoc, diag::err_omp_expected_omp_depend_t_lvalue) << 1 << RefExpr->getType() << RefExpr->getSourceRange(); continue; } } else { // OpenMP 5.0 [2.17.11, Restrictions] // List items used in depend clauses cannot be zero-length array sections. // List items used in depend clauses cannot be zero-length array // sections. QualType ExprTy = RefExpr->getType().getNonReferenceType(); const auto *OASE = dyn_cast<OMPArraySectionExpr>(SimpleExpr); if (OASE) { QualType BaseType = OMPArraySectionExpr::getBaseOriginalType(OASE->getBase()); if (const auto *ATy = BaseType->getAsArrayTypeUnsafe()) ExprTy = ATy->getElementType(); else ExprTy = BaseType->getPointeeType(); ExprTy = ExprTy.getNonReferenceType(); const Expr *Length = OASE->getLength(); Expr::EvalResult Result; if (Length && !Length->isValueDependent() && Loading @@ -15388,13 +15431,30 @@ Sema::ActOnOpenMPDependClause(OpenMPDependClauseKind DepKind, } } // OpenMP 5.0, 2.17.11 depend Clause, Restrictions, C/C++ // List items used in depend clauses with the in, out, inout or // mutexinoutset dependence types cannot be expressions of the // omp_depend_t type. if (!RefExpr->isValueDependent() && !RefExpr->isTypeDependent() && !RefExpr->isInstantiationDependent() && !RefExpr->containsUnexpandedParameterPack() && (OMPDependTFound && DSAStack->getOMPDependT().getTypePtr() == ExprTy.getTypePtr())) { Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item) << 1 << RefExpr->getSourceRange(); continue; } auto *ASE = dyn_cast<ArraySubscriptExpr>(SimpleExpr); if (!RefExpr->IgnoreParenImpCasts()->isLValue() || (ASE && !ASE->getBase()->getType().getNonReferenceType()->isPointerType() && !ASE->getBase() ->getType() .getNonReferenceType() ->isPointerType() && !ASE->getBase()->getType().getNonReferenceType()->isArrayType())) { Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item) << RefExpr->getSourceRange(); << (LangOpts.OpenMP >= 50 ? 1 : 0) << RefExpr->getSourceRange(); continue; } Loading @@ -15406,10 +15466,11 @@ Sema::ActOnOpenMPDependClause(OpenMPDependClauseKind DepKind, } if (!Res.isUsable() && !isa<OMPArraySectionExpr>(SimpleExpr)) { Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item) << RefExpr->getSourceRange(); << (LangOpts.OpenMP >= 50 ? 1 : 0) << RefExpr->getSourceRange(); continue; } } } Vars.push_back(RefExpr->IgnoreParenImpCasts()); } Loading
clang/include/clang/Basic/DiagnosticSemaKinds.td +1 −1 Original line number Diff line number Diff line Loading @@ -9633,7 +9633,7 @@ def err_omp_expected_var_name_member_expr : Error< def err_omp_expected_var_name_member_expr_or_array_item : Error< "expected variable name%select{|, data member of current class}0, array element or array section">; def err_omp_expected_addressable_lvalue_or_array_item : Error< "expected addressable lvalue expression, array element or array section">; "expected addressable lvalue expression, array element or array section%select{| of non 'omp_depend_t' type}0">; def err_omp_expected_named_var_member_or_array_expression: Error< "expected expression containing only member accesses and/or array sections based on named variables">; def err_omp_bit_fields_forbidden_in_clause : Error< Loading
clang/include/clang/Basic/OpenMPKinds.def +1 −0 Original line number Diff line number Diff line Loading @@ -384,6 +384,7 @@ OPENMP_DEPEND_KIND(in) OPENMP_DEPEND_KIND(out) OPENMP_DEPEND_KIND(inout) OPENMP_DEPEND_KIND(mutexinoutset) OPENMP_DEPEND_KIND(depobj) OPENMP_DEPEND_KIND(source) OPENMP_DEPEND_KIND(sink) Loading
clang/lib/CodeGen/CGOpenMPRuntime.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -5214,6 +5214,7 @@ static RTLDependenceKindTy translateDependencyKind(OpenMPDependClauseKind K) { break; case OMPC_DEPEND_source: case OMPC_DEPEND_sink: case OMPC_DEPEND_depobj: case OMPC_DEPEND_unknown: llvm_unreachable("Unknown task dependence type"); } Loading
clang/lib/Parse/ParseOpenMP.cpp +1 −3 Original line number Diff line number Diff line Loading @@ -3198,9 +3198,7 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind, Data.RLoc = Tok.getLocation(); if (!T.consumeClose()) Data.RLoc = T.getCloseLocation(); return (Kind == OMPC_depend && Data.ExtraModifier != OMPC_DEPEND_unknown && Vars.empty()) || (Kind != OMPC_depend && Kind != OMPC_map && Vars.empty()) || return (Kind != OMPC_depend && Kind != OMPC_map && Vars.empty()) || (MustHaveTail && !Data.TailExpr) || InvalidReductionId || IsInvalidMapperModifier; } Loading
clang/lib/Sema/SemaOpenMP.cpp +99 −38 Original line number Diff line number Diff line Loading @@ -12247,8 +12247,9 @@ OMPClause *Sema::ActOnOpenMPUpdateClause(OpenMPDependClauseKind Kind, SourceLocation LParenLoc, SourceLocation EndLoc) { if (Kind == OMPC_DEPEND_unknown || Kind == OMPC_DEPEND_source || Kind == OMPC_DEPEND_sink) { unsigned Except[] = {OMPC_DEPEND_source, OMPC_DEPEND_sink}; Kind == OMPC_DEPEND_sink || Kind == OMPC_DEPEND_depobj) { unsigned Except[] = {OMPC_DEPEND_source, OMPC_DEPEND_sink, OMPC_DEPEND_depobj}; Diag(KindKwLoc, diag::err_omp_unexpected_clause_value) << getListOfPossibleValues(OMPC_depend, /*First=*/0, /*Last=*/OMPC_DEPEND_unknown, Except) Loading Loading @@ -15208,13 +15209,15 @@ OMPClause *Sema::ActOnOpenMPFlushClause(ArrayRef<Expr *> VarList, } /// Tries to find omp_depend_t. type. static bool findOMPDependT(Sema &S, SourceLocation Loc, DSAStackTy *Stack) { static bool findOMPDependT(Sema &S, SourceLocation Loc, DSAStackTy *Stack, bool Diagnose = true) { QualType OMPDependT = Stack->getOMPDependT(); if (!OMPDependT.isNull()) return true; IdentifierInfo *II = &S.PP.getIdentifierTable().get("omp_depend_t"); ParsedType PT = S.getTypeName(*II, Loc, S.getCurScope()); if (!PT.getAsOpaquePtr() || PT.get().isNull()) { if (Diagnose) S.Diag(Loc, diag::err_omp_implied_type_not_found) << "omp_depend_t"; return false; } Loading Loading @@ -15264,8 +15267,15 @@ Sema::ActOnOpenMPDependClause(OpenMPDependClauseKind DepKind, if ((DSAStack->getCurrentDirective() != OMPD_ordered || DSAStack->getCurrentDirective() == OMPD_depobj) && (DepKind == OMPC_DEPEND_unknown || DepKind == OMPC_DEPEND_source || DepKind == OMPC_DEPEND_sink)) { unsigned Except[] = {OMPC_DEPEND_source, OMPC_DEPEND_sink}; DepKind == OMPC_DEPEND_sink || ((LangOpts.OpenMP < 50 || DSAStack->getCurrentDirective() == OMPD_depobj) && DepKind == OMPC_DEPEND_depobj))) { SmallVector<unsigned, 3> Except; Except.push_back(OMPC_DEPEND_source); Except.push_back(OMPC_DEPEND_sink); if (LangOpts.OpenMP < 50 || DSAStack->getCurrentDirective() == OMPD_depobj) Except.push_back(OMPC_DEPEND_depobj); Diag(DepLoc, diag::err_omp_unexpected_clause_value) << getListOfPossibleValues(OMPC_depend, /*First=*/0, /*Last=*/OMPC_DEPEND_unknown, Except) Loading Loading @@ -15371,11 +15381,44 @@ Sema::ActOnOpenMPDependClause(OpenMPDependClauseKind DepKind, continue; } OpsOffs.emplace_back(RHS, OOK); } else { bool OMPDependTFound = LangOpts.OpenMP >= 50; if (OMPDependTFound) OMPDependTFound = findOMPDependT(*this, StartLoc, DSAStack, DepKind == OMPC_DEPEND_depobj); if (DepKind == OMPC_DEPEND_depobj) { // OpenMP 5.0, 2.17.11 depend Clause, Restrictions, C/C++ // List items used in depend clauses with the depobj dependence type // must be expressions of the omp_depend_t type. if (!RefExpr->isValueDependent() && !RefExpr->isTypeDependent() && !RefExpr->isInstantiationDependent() && !RefExpr->containsUnexpandedParameterPack() && (OMPDependTFound && !Context.hasSameUnqualifiedType(DSAStack->getOMPDependT(), RefExpr->getType()))) { Diag(ELoc, diag::err_omp_expected_omp_depend_t_lvalue) << 0 << RefExpr->getType() << RefExpr->getSourceRange(); continue; } if (!RefExpr->isLValue()) { Diag(ELoc, diag::err_omp_expected_omp_depend_t_lvalue) << 1 << RefExpr->getType() << RefExpr->getSourceRange(); continue; } } else { // OpenMP 5.0 [2.17.11, Restrictions] // List items used in depend clauses cannot be zero-length array sections. // List items used in depend clauses cannot be zero-length array // sections. QualType ExprTy = RefExpr->getType().getNonReferenceType(); const auto *OASE = dyn_cast<OMPArraySectionExpr>(SimpleExpr); if (OASE) { QualType BaseType = OMPArraySectionExpr::getBaseOriginalType(OASE->getBase()); if (const auto *ATy = BaseType->getAsArrayTypeUnsafe()) ExprTy = ATy->getElementType(); else ExprTy = BaseType->getPointeeType(); ExprTy = ExprTy.getNonReferenceType(); const Expr *Length = OASE->getLength(); Expr::EvalResult Result; if (Length && !Length->isValueDependent() && Loading @@ -15388,13 +15431,30 @@ Sema::ActOnOpenMPDependClause(OpenMPDependClauseKind DepKind, } } // OpenMP 5.0, 2.17.11 depend Clause, Restrictions, C/C++ // List items used in depend clauses with the in, out, inout or // mutexinoutset dependence types cannot be expressions of the // omp_depend_t type. if (!RefExpr->isValueDependent() && !RefExpr->isTypeDependent() && !RefExpr->isInstantiationDependent() && !RefExpr->containsUnexpandedParameterPack() && (OMPDependTFound && DSAStack->getOMPDependT().getTypePtr() == ExprTy.getTypePtr())) { Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item) << 1 << RefExpr->getSourceRange(); continue; } auto *ASE = dyn_cast<ArraySubscriptExpr>(SimpleExpr); if (!RefExpr->IgnoreParenImpCasts()->isLValue() || (ASE && !ASE->getBase()->getType().getNonReferenceType()->isPointerType() && !ASE->getBase() ->getType() .getNonReferenceType() ->isPointerType() && !ASE->getBase()->getType().getNonReferenceType()->isArrayType())) { Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item) << RefExpr->getSourceRange(); << (LangOpts.OpenMP >= 50 ? 1 : 0) << RefExpr->getSourceRange(); continue; } Loading @@ -15406,10 +15466,11 @@ Sema::ActOnOpenMPDependClause(OpenMPDependClauseKind DepKind, } if (!Res.isUsable() && !isa<OMPArraySectionExpr>(SimpleExpr)) { Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item) << RefExpr->getSourceRange(); << (LangOpts.OpenMP >= 50 ? 1 : 0) << RefExpr->getSourceRange(); continue; } } } Vars.push_back(RefExpr->IgnoreParenImpCasts()); }