https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/227419
>From e2051405101dd3b1edded677110f4fa79cab90fe Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek <[email protected]> Date: Tue, 29 Sep 2026 08:49:21 -0500 Subject: [PATCH 1/2] [flang][OpenMP] Remember decision of allowing past/future clause When a deprecated or a future clause is used on a directive, and it is allowed with a warning, remember that decision and consider that clause allowed on that directive in all subsequent checks. Introduce an OpenMPKartoffel warning category to guard these warnings (and the corresponding -Wopenmp-kartoffel option). --- flang/include/flang/Semantics/openmp-utils.h | 19 +++++++ flang/include/flang/Semantics/semantics.h | 7 +++ .../include/flang/Support/Fortran-features.h | 3 +- flang/lib/Lower/OpenMP/Decomposer.cpp | 4 +- flang/lib/Semantics/check-omp-loop.cpp | 2 +- flang/lib/Semantics/check-omp-structure.cpp | 50 ++++++++++++------- flang/lib/Semantics/check-omp-structure.h | 2 + flang/lib/Semantics/check-omp-variant.cpp | 8 +-- flang/lib/Semantics/openmp-utils.cpp | 39 +++++++++++++-- flang/lib/Semantics/semantics.cpp | 7 +++ flang/lib/Support/Fortran-features.cpp | 1 + .../OpenMP/scope-allocate-clause.f90 | 4 +- .../test/Semantics/OpenMP/affinity-clause.f90 | 4 +- .../OpenMP/allocate-clause-version.f90 | 10 ++-- flang/test/Semantics/OpenMP/allocate_do1.f90 | 6 +-- flang/test/Semantics/OpenMP/atomic.f90 | 16 +++--- .../Semantics/OpenMP/clause-validity02.f90 | 2 +- .../OpenMP/declarative-directive01.f90 | 4 +- .../Semantics/OpenMP/declare-target01.f90 | 26 +++++----- .../Semantics/OpenMP/declare-target02.f90 | 30 +++++------ .../Semantics/OpenMP/declare-target06.f90 | 2 +- .../OpenMP/if-clause-45-suggestion.f90 | 6 +-- flang/test/Semantics/OpenMP/if-clause-45.f90 | 29 ++--------- .../OpenMP/if-clause-50-suggestion.f90 | 4 +- flang/test/Semantics/OpenMP/if-clause-50.f90 | 6 +-- flang/test/Semantics/OpenMP/requires04.f90 | 2 +- flang/test/Semantics/OpenMP/requires05.f90 | 2 +- .../Semantics/OpenMP/threadset-clause.f90 | 6 +-- 28 files changed, 180 insertions(+), 121 deletions(-) diff --git a/flang/include/flang/Semantics/openmp-utils.h b/flang/include/flang/Semantics/openmp-utils.h index 769140a3147ed..c31459f256f62 100644 --- a/flang/include/flang/Semantics/openmp-utils.h +++ b/flang/include/flang/Semantics/openmp-utils.h @@ -23,6 +23,7 @@ #include "llvm/ADT/APInt.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Frontend/OpenMP/OMPContext.h" #include "llvm/Frontend/OpenMP/OMPVersion.h" @@ -54,6 +55,24 @@ template <typename T, typename U = std::remove_const_t<T>> U AsRvalue(T &t) { template <typename T> T &&AsRvalue(T &&t) { return std::move(t); } +struct SemanticOverrides { + // Map of clauses and which directives they are considered to be allowed on + // for the purpose of this compilation despite not being allowed by strict + // interpretation of the selected spec version. + // This is to record cases where we allow a clause because a past/future + // spec allows it. This is needed for consistent treatment of clauses as + // allowed/disallowed. + llvm::DenseMap<llvm::omp::Clause, llvm::omp::Directives> allowedClauses; +}; + +bool IsClauseAllowedOnDirective(llvm::omp::Clause clauseId, + llvm::omp::Directive dirId, llvm::omp::Version ver, + SemanticOverrides *overrides); + +bool IsClauseAllowedOnDirective(llvm::omp::Clause clauseId, + llvm::omp::Directive dirId, llvm::omp::Version version, + SemanticsContext *semaCtx); + const Scope &GetScopingUnit(const Scope &scope); const Scope &GetProgramUnit(const Scope &scope); diff --git a/flang/include/flang/Semantics/semantics.h b/flang/include/flang/Semantics/semantics.h index dd81b1d8cf854..d1365c4e7f46b 100644 --- a/flang/include/flang/Semantics/semantics.h +++ b/flang/include/flang/Semantics/semantics.h @@ -56,6 +56,10 @@ class Symbol; class CommonBlockMap; using CommonBlockList = std::vector<std::pair<SymbolRef, std::size_t>>; +namespace omp { +struct SemanticOverrides; +} + using ConstructNode = std::variant<const parser::AssociateConstruct *, const parser::BlockConstruct *, const parser::CaseConstruct *, const parser::ChangeTeamConstruct *, const parser::CriticalConstruct *, @@ -411,6 +415,8 @@ class SemanticsContext { return branchTargets_.find(statementPosition) != branchTargets_.end(); } + omp::SemanticOverrides &GetOmpSemanticOverrides(); + private: struct ScopeIndexComparator { bool operator()(parser::CharBlock, parser::CharBlock) const; @@ -472,6 +478,7 @@ class SemanticsContext { UnorderedSymbolSet isUsed_; std::set<const parser::AccObject *> accObjectDuplicates_; bool anyOpenACCDataMapping_{false}; + std::unique_ptr<omp::SemanticOverrides> ompOverrides_; std::list<ProgramTree> programTrees_; }; diff --git a/flang/include/flang/Support/Fortran-features.h b/flang/include/flang/Support/Fortran-features.h index 06372bfc2cc1e..5d13ab573deb8 100644 --- a/flang/include/flang/Support/Fortran-features.h +++ b/flang/include/flang/Support/Fortran-features.h @@ -90,7 +90,8 @@ ENUM_CLASS(UsageWarning, Portability, PointerToUndefinable, UsedUndefinedVariable, BadValueInDeadCode, AssumedTypeSizeDummy, MisplacedIgnoreTKR, NamelistParameter, ImpureFinalInPure, IgnoredNoReallocateLHS, ExperimentalOption, IoImpliedDoIndexConflict, - BOZLiteralTruncation, IntentInActualForDefaultIntent, BindCArrayDescriptor) + BOZLiteralTruncation, IntentInActualForDefaultIntent, BindCArrayDescriptor, + OpenMPKartoffel) using LanguageFeatures = EnumSet<LanguageFeature, LanguageFeature_enumSize>; using UsageWarnings = EnumSet<UsageWarning, UsageWarning_enumSize>; diff --git a/flang/lib/Lower/OpenMP/Decomposer.cpp b/flang/lib/Lower/OpenMP/Decomposer.cpp index 157b52a4837df..78598f50e3efc 100644 --- a/flang/lib/Lower/OpenMP/Decomposer.cpp +++ b/flang/lib/Lower/OpenMP/Decomposer.cpp @@ -17,6 +17,7 @@ #include "flang/Lower/PFTBuilder.h" #include "flang/Optimizer/Support/FatalError.h" #include "flang/Parser/provenance.h" +#include "flang/Semantics/openmp-utils.h" #include "flang/Semantics/semantics.h" #include "mlir/IR/BuiltinOps.h" #include "llvm/ADT/ArrayRef.h" @@ -65,7 +66,8 @@ struct ConstructDecomposition { bool isClauseAllowedOnDirective(llvm::omp::Clause clauseId, llvm::omp::Directive dirId, llvm::omp::Version version) { - return llvm::omp::isAllowedClauseForDirective(dirId, clauseId, version); + return semantics::omp::IsClauseAllowedOnDirective(clauseId, dirId, version, + &semaCtx); } semantics::SemanticsContext &semaCtx; diff --git a/flang/lib/Semantics/check-omp-loop.cpp b/flang/lib/Semantics/check-omp-loop.cpp index 1e5df80790452..f57714daeaf6c 100644 --- a/flang/lib/Semantics/check-omp-loop.cpp +++ b/flang/lib/Semantics/check-omp-loop.cpp @@ -573,7 +573,7 @@ void OmpStructureChecker::CheckIterationVariables( auto range{dsa.equal_range(host)}; for (auto found{range.first}; found != range.second; ++found) { llvm::omp::Clause id{found->second.clauseId}; - if (!llvm::omp::isAllowedClauseForDirective(dirId, id, version)) { + if (!IsClauseAllowedOnDirective(id, dirId, version, &context_)) { continue; } if (id == llvm::omp::Clause::OMPC_private || diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp index 09b6c6bc3449f..a2189196707d4 100644 --- a/flang/lib/Semantics/check-omp-structure.cpp +++ b/flang/lib/Semantics/check-omp-structure.cpp @@ -529,8 +529,8 @@ bool OmpStructureChecker::IsAllowedClause(llvm::omp::Clause clauseId) { if (GetDirectiveNest(ContextSelectorNest) > 0) { return true; } - return llvm::omp::isAllowedClauseForDirective(GetContext().directive, - clauseId, context_.langOptions().getOpenMPVersion()); + return IsClauseAllowedOnDirective(clauseId, GetContext().directive, + context_.langOptions().getOpenMPVersion(), &context_); } bool OmpStructureChecker::CheckAllowedClause(llvm::omp::Clause clauseId, @@ -547,26 +547,27 @@ bool OmpStructureChecker::CheckAllowedClause(llvm::omp::Clause clauseId, llvm::omp::Version version{context_.langOptions().getOpenMPVersion()}; - if (!llvm::omp::isAllowedClauseForDirective(dirId, clauseId, version)) { + if (!IsClauseAllowedOnDirective(clauseId, dirId, version, &context_)) { llvm::omp::Version allowedInVersion{[&] { for (llvm::omp::Version v : llvm::omp::getOpenMPVersions()) { if (v <= version) { continue; } - if (llvm::omp::isAllowedClauseForDirective(dirId, clauseId, v)) { + if (IsClauseAllowedOnDirective(clauseId, dirId, v, &context_)) { return v; } } return llvm::omp::Version(); }()}; - // Only report it if there is a later version that allows it. - // If it's not allowed at all, it will be reported by CheckAllowed. if (allowedInVersion) { - context_.Say(clauseSource, - "%s clause is not allowed on %s directive in %s, %s"_err_en_US, + context_.Warn(common::UsageWarning::OpenMPKartoffel, clauseSource, + "%s clause is not allowed on %s directive in %s, %s"_warn_en_US, GetUpperName(clauseId, version), GetUpperName(dirId, version), ThisVersion(version), TryVersion(allowedInVersion)); + if (!context_.warningsAreErrors()) { + SetAllowedClauseOverride(clauseId, dirId); + } } else { context_.Say(clauseSource, "%s clause is not allowed on %s directive"_err_en_US, @@ -578,6 +579,12 @@ bool OmpStructureChecker::CheckAllowedClause(llvm::omp::Clause clauseId, return true; } +void OmpStructureChecker::SetAllowedClauseOverride( + llvm::omp::Clause clauseId, llvm::omp::Directive dirId) { + SemanticOverrides &overrides{context_.GetOmpSemanticOverrides()}; + overrides.allowedClauses[clauseId].set(dirId); +} + void OmpStructureChecker::AnalyzeObject(const parser::OmpObject &object) { if (GetCommonBlockFromObj(object) || std::holds_alternative<parser::OmpObject::Invalid>(object.u)) { @@ -1209,7 +1216,8 @@ void OmpStructureChecker::CheckClauses(parser::OmpDirectiveName dirName, // Prepare the requiredSet relevant to the current OpenMP version. llvm::omp::Clauses requiredSet; for (llvm::omp::Clause id : directiveClausesMap_[dirId].requiredOneOf) { - if (IsAllowedClause(id)) { + // Do not report overridden clauses as required. + if (llvm::omp::isAllowedClauseForDirective(dirId, id, version)) { requiredSet.set(id); } } @@ -2820,8 +2828,12 @@ void OmpStructureChecker::Leave(const parser::OmpDeclareTargetDirective &x) { } llvm::omp::Version version{context_.langOptions().getOpenMPVersion()}; if (toClause && version >= 52) { - context_.Warn(common::UsageWarning::OpenMPUsage, toClause->source, + context_.Warn(common::UsageWarning::OpenMPKartoffel, toClause->source, "The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead."_warn_en_US); + if (!context_.warningsAreErrors()) { + SetAllowedClauseOverride(llvm::omp::Clause::OMPC_to, + llvm::omp::Directive::OMPD_declare_target); + } } } @@ -3236,8 +3248,8 @@ struct TaskgraphVisitor { } llvm::omp::Version version{context_.langOptions().getOpenMPVersion()}; - bool allowsNogroup{llvm::omp::isAllowedClauseForDirective( - leafs[0], llvm::omp::Clause::OMPC_nogroup, version)}; + bool allowsNogroup{IsClauseAllowedOnDirective( + llvm::omp::Clause::OMPC_nogroup, leafs[0], version, &context_)}; if (allowsNogroup) { if (!nogroup) { @@ -5699,15 +5711,16 @@ static bool IsPredefinedHandle(const parser::Name &name, } static bool ClauseHasTargetEffect(llvm::omp::Directive directive, - llvm::omp::Clause clause, llvm::omp::Version version) { + llvm::omp::Clause clause, llvm::omp::Version version, + SemanticsContext &semaCtx) { llvm::ArrayRef<llvm::omp::Directive> leafs{ llvm::omp::getLeafConstructsOrSelf(directive)}; if (!llvm::is_contained(leafs, llvm::omp::Directive::OMPD_target)) { return false; } if (leafs.size() == 1) { - return llvm::omp::isAllowedClauseForDirective( - llvm::omp::Directive::OMPD_target, clause, version); + return IsClauseAllowedOnDirective( + clause, llvm::omp::Directive::OMPD_target, version, &semaCtx); } // Compound distribution can override direct TARGET clause permission. @@ -5726,8 +5739,8 @@ static bool ClauseHasTargetEffect(llvm::omp::Directive directive, return (llvm::omp::isDataSharingAttributeClause(clause, version) || clause == llvm::omp::Clause::OMPC_map) && - llvm::omp::isAllowedClauseForDirective( - llvm::omp::Directive::OMPD_target, clause, version); + IsClauseAllowedOnDirective( + clause, llvm::omp::Directive::OMPD_target, version, &semaCtx); } void OmpStructureChecker::CheckUsesAllocatorsSpec( @@ -5803,7 +5816,8 @@ void OmpStructureChecker::CheckUsesAllocatorsSpec( id != llvm::omp::Clause::OMPC_map) { continue; } - if (!ClauseHasTargetEffect(GetContext().directive, id, version)) { + if (!ClauseHasTargetEffect( + GetContext().directive, id, version, context_)) { continue; } const parser::OmpObjectList *objects{GetOmpObjectList(clause)}; diff --git a/flang/lib/Semantics/check-omp-structure.h b/flang/lib/Semantics/check-omp-structure.h index a77506e329934..b52df8551a70b 100644 --- a/flang/lib/Semantics/check-omp-structure.h +++ b/flang/lib/Semantics/check-omp-structure.h @@ -375,6 +375,8 @@ class OmpStructureChecker : public OmpStructureCheckerBase { bool IsAllowedClause(llvm::omp::Clause clauseId); bool CheckAllowedClause(llvm::omp::Clause clauseId, parser::CharBlock clauseSource, llvm::omp::Directive dirId); + void SetAllowedClauseOverride( + llvm::omp::Clause clauseId, llvm::omp::Directive dirId); void CheckArgumentObjectKind(const parser::OmpClause &x); void CheckDirectiveSpelling( parser::CharBlock spelling, llvm::omp::Directive id); diff --git a/flang/lib/Semantics/check-omp-variant.cpp b/flang/lib/Semantics/check-omp-variant.cpp index ac745accf95a3..7add875c96d88 100644 --- a/flang/lib/Semantics/check-omp-variant.cpp +++ b/flang/lib/Semantics/check-omp-variant.cpp @@ -659,8 +659,8 @@ void OmpStructureChecker::CheckTraitRequires( for (const parser::OmpTraitProperty &property : properties) { auto clauseId{*GetClauseFromProperty(property)}; - if (!llvm::omp::isAllowedClauseForDirective( - llvm::omp::OMPD_requires, clauseId, version)) { + if (!IsClauseAllowedOnDirective( + clauseId, llvm::omp::OMPD_requires, version, &context_)) { context_.Say(property.source, "%s trait requires a clause from the requirement clause set"_err_en_US, parser::ToUpperCaseLetters(traitName.ToString())); @@ -684,8 +684,8 @@ void OmpStructureChecker::CheckTraitSimd( for (const parser::OmpTraitProperty &property : properties) { auto clauseId{*GetClauseFromProperty(property)}; - if (!llvm::omp::isAllowedClauseForDirective( - llvm::omp::OMPD_declare_simd, clauseId, version)) { + if (!IsClauseAllowedOnDirective( + clauseId, llvm::omp::OMPD_declare_simd, version, &context_)) { context_.Say(property.source, "%s trait requires a clause that is allowed on the %s directive"_err_en_US, parser::ToUpperCaseLetters(traitName.ToString()), diff --git a/flang/lib/Semantics/openmp-utils.cpp b/flang/lib/Semantics/openmp-utils.cpp index a341cf4fa1706..794a748592bce 100644 --- a/flang/lib/Semantics/openmp-utils.cpp +++ b/flang/lib/Semantics/openmp-utils.cpp @@ -59,6 +59,33 @@ namespace Fortran::semantics::omp { using namespace Fortran::parser::omp; +static SemanticOverrides *GetSemanticOverridesOrNull( + SemanticsContext *semaCtx) { + if (semaCtx) { + return &semaCtx->GetOmpSemanticOverrides(); + } + return nullptr; +} + +bool IsClauseAllowedOnDirective(llvm::omp::Clause clauseId, + llvm::omp::Directive dirId, llvm::omp::Version version, + SemanticOverrides *overrides) { + if (overrides) { + auto f{overrides->allowedClauses.find(clauseId)}; + if (f != overrides->allowedClauses.end() && f->second.test(dirId)) { + return true; + } + } + return llvm::omp::isAllowedClauseForDirective(dirId, clauseId, version); +} + +bool IsClauseAllowedOnDirective(llvm::omp::Clause clauseId, + llvm::omp::Directive dirId, llvm::omp::Version version, + SemanticsContext *semaCtx) { + return IsClauseAllowedOnDirective( + clauseId, dirId, version, GetSemanticOverridesOrNull(semaCtx)); +} + const Scope &GetScopingUnit(const Scope &scope) { const Scope *iter{&scope}; for (; !iter->IsTopLevel(); iter = &iter->parent()) { @@ -1304,10 +1331,11 @@ std::pair<WithReason<int64_t>, bool> GetAffectedNestDepthWithReason( const parser::OmpDirectiveSpecification &spec, llvm::omp::Version version, SemanticsContext *semaCtx) { llvm::omp::Directive dir{spec.DirId()}; - bool allowsCollapse{llvm::omp::isAllowedClauseForDirective( - dir, llvm::omp::Clause::OMPC_collapse, version)}; - bool allowsOrdered{llvm::omp::isAllowedClauseForDirective( - dir, llvm::omp::Clause::OMPC_ordered, version)}; + SemanticOverrides *overrides{GetSemanticOverridesOrNull(semaCtx)}; + bool allowsCollapse{IsClauseAllowedOnDirective( + llvm::omp::Clause::OMPC_collapse, dir, version, overrides)}; + bool allowsOrdered{IsClauseAllowedOnDirective( + llvm::omp::Clause::OMPC_ordered, dir, version, overrides)}; if (allowsCollapse || allowsOrdered) { auto [ccount, creason]{GetArgumentValueWithReason( @@ -1533,8 +1561,9 @@ WithReason<int64_t> GetRectangularNestDepthWithReason( auto clauseAt{ llvm::find_if(spec.Clauses().v, [&](const parser::OmpClause &c) { llvm::omp::Clause clauseId{c.Id()}; + SemanticOverrides *overrides{GetSemanticOverridesOrNull(semaCtx)}; return llvm::is_contained(clauses, clauseId) && - llvm::omp::isAllowedClauseForDirective(dirId, clauseId, version); + IsClauseAllowedOnDirective(clauseId, dirId, version, overrides); })}; if (clauseAt != spec.Clauses().v.end()) { depth.reason.Say(clauseAt->source, diff --git a/flang/lib/Semantics/semantics.cpp b/flang/lib/Semantics/semantics.cpp index 761ade6c1e97d..b371454c58311 100644 --- a/flang/lib/Semantics/semantics.cpp +++ b/flang/lib/Semantics/semantics.cpp @@ -1005,4 +1005,11 @@ bool SemanticsContext::IsSymbolUsed(const Symbol &symbol) const { return isUsed_.find(symbol) != isUsed_.end(); } +omp::SemanticOverrides &SemanticsContext::GetOmpSemanticOverrides() { + if (!ompOverrides_) { + ompOverrides_ = std::make_unique<omp::SemanticOverrides>(); + } + return DEREF(ompOverrides_.get()); +} + } // namespace Fortran::semantics diff --git a/flang/lib/Support/Fortran-features.cpp b/flang/lib/Support/Fortran-features.cpp index 4ae05994d98a7..d23595df9ac9d 100644 --- a/flang/lib/Support/Fortran-features.cpp +++ b/flang/lib/Support/Fortran-features.cpp @@ -198,6 +198,7 @@ LanguageFeatureControl::LanguageFeatureControl() { warnUsage_.set(UsageWarning::ZeroDoStep); warnUsage_.set(UsageWarning::UnusedForallIndex); warnUsage_.set(UsageWarning::OpenMPUsage); + warnUsage_.set(UsageWarning::OpenMPKartoffel); warnUsage_.set(UsageWarning::DataLength); warnUsage_.set(UsageWarning::IgnoredDirective); warnUsage_.set(UsageWarning::HomonymousSpecific); diff --git a/flang/test/Integration/OpenMP/scope-allocate-clause.f90 b/flang/test/Integration/OpenMP/scope-allocate-clause.f90 index 50bd1ab288d8d..472b4c4f2b3b4 100644 --- a/flang/test/Integration/OpenMP/scope-allocate-clause.f90 +++ b/flang/test/Integration/OpenMP/scope-allocate-clause.f90 @@ -14,9 +14,9 @@ ! RUN: %flang_fc1 -emit-hlfir %openmp_flags -fopenmp-version=52 -o - %s 2>&1 | FileCheck %s ! RUN: %flang_fc1 -emit-llvm %openmp_flags -fopenmp-version=52 -o - %s 2>&1 | FileCheck %s --check-prefix=LLVM -! RUN: not %flang_fc1 -fsyntax-only %openmp_flags -fopenmp-version=51 %s 2>&1 | FileCheck %s --check-prefix=VERSION51 +! RUN: %flang_fc1 -emit-hlfir %openmp_flags -fopenmp-version=51 -o - %s 2>&1 | FileCheck %s --check-prefixes=CHECK,VERSION51 -! VERSION51: error: {{.*}}ALLOCATE +! VERSION51: warning: {{.*}}ALLOCATE subroutine scope_allocator_omitted(x, y) integer :: x, y diff --git a/flang/test/Semantics/OpenMP/affinity-clause.f90 b/flang/test/Semantics/OpenMP/affinity-clause.f90 index 1b27ff242a9c0..3c739933712f4 100644 --- a/flang/test/Semantics/OpenMP/affinity-clause.f90 +++ b/flang/test/Semantics/OpenMP/affinity-clause.f90 @@ -1,8 +1,8 @@ -!RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=45 +!RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=45 -Werror -Wno-experimental-option subroutine f00(x) integer :: x(10) -!ERROR: AFFINITY clause is not allowed on TASK directive in OpenMP v4.5, try -fopenmp-version=50 +!ERROR: AFFINITY clause is not allowed on TASK directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-kartoffel] !$omp task affinity(x) x = x + 1 !$omp end task diff --git a/flang/test/Semantics/OpenMP/allocate-clause-version.f90 b/flang/test/Semantics/OpenMP/allocate-clause-version.f90 index 42db4e500b37d..cd25b77eee7e8 100644 --- a/flang/test/Semantics/OpenMP/allocate-clause-version.f90 +++ b/flang/test/Semantics/OpenMP/allocate-clause-version.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp -fopenmp-version=45 +! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp -fopenmp-version=45 -Werror -Wno-experimental-option ! The ALLOCATE clause was introduced in OpenMP 5.0, so before that it must be ! rejected rather than accepted and handed to lowering, which cannot decompose @@ -17,19 +17,19 @@ subroutine allocate_pre50(n, a, b) real :: a(n), b(n) real :: t - !ERROR: ALLOCATE clause is not allowed on PARALLEL directive in OpenMP v4.5, try -fopenmp-version=50 + !ERROR: ALLOCATE clause is not allowed on PARALLEL directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-kartoffel] !$omp parallel private(t) allocate(t) t = a(1) b(1) = t !$omp end parallel - !ERROR: ALLOCATE clause is not allowed on SINGLE directive in OpenMP v4.5, try -fopenmp-version=50 + !ERROR: ALLOCATE clause is not allowed on SINGLE directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-kartoffel] !$omp single private(t) allocate(t) t = a(1) b(1) = t !$omp end single - !ERROR: ALLOCATE clause is not allowed on TASK directive in OpenMP v4.5, try -fopenmp-version=50 + !ERROR: ALLOCATE clause is not allowed on TASK directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-kartoffel] !$omp task private(t) allocate(t) t = a(1) b(1) = t @@ -37,7 +37,7 @@ subroutine allocate_pre50(n, a, b) ! The form reported in llvm-project#211430, where the ungated clause reached ! lowering and crashed it. - !ERROR: ALLOCATE clause is not allowed on TARGET TEAMS DISTRIBUTE PARALLEL DO directive in OpenMP v4.5, try -fopenmp-version=50 + !ERROR: ALLOCATE clause is not allowed on TARGET TEAMS DISTRIBUTE PARALLEL DO directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-kartoffel] !$omp target teams distribute parallel do private(t) allocate(t) do i = 1, n t = a(i) diff --git a/flang/test/Semantics/OpenMP/allocate_do1.f90 b/flang/test/Semantics/OpenMP/allocate_do1.f90 index 1be215fb42698..ac17e602c8843 100644 --- a/flang/test/Semantics/OpenMP/allocate_do1.f90 +++ b/flang/test/Semantics/OpenMP/allocate_do1.f90 @@ -1,4 +1,4 @@ -!RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=45 +!RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=45 -Werror -Wno-experimental-option module all_mod integer, parameter :: N = 100 integer(kind=4), dimension(N) :: AAA @@ -21,7 +21,7 @@ subroutine initialize() subroutine test_omp_do() use all_mod !$omp parallel shared(AAA,BBB,CCC,DDD,val) - !ERROR: ALLOCATE clause is not allowed on DO directive in OpenMP v4.5, try -fopenmp-version=50 + !ERROR: ALLOCATE clause is not allowed on DO directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-kartoffel] !ERROR: 'allocator-simple-modifier' modifier is not supported on ALLOCATE clause in OpenMP v4.5, try -fopenmp-version=50 !$omp do private(CCC, val) allocate(0:CCC, val) do i=1,N @@ -35,7 +35,7 @@ end subroutine test_omp_do subroutine test_omp_parallel_do() use all_mod - !ERROR: ALLOCATE clause is not allowed on PARALLEL DO directive in OpenMP v4.5, try -fopenmp-version=50 + !ERROR: ALLOCATE clause is not allowed on PARALLEL DO directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-kartoffel] !ERROR: 'allocator-simple-modifier' modifier is not supported on ALLOCATE clause in OpenMP v4.5, try -fopenmp-version=50 !$omp parallel do private(CCC, val) allocate(0:CCC, val) shared(AAA,BBB,DDD) do i=1,N diff --git a/flang/test/Semantics/OpenMP/atomic.f90 b/flang/test/Semantics/OpenMP/atomic.f90 index 25011513136ac..c6caafc6072b9 100644 --- a/flang/test/Semantics/OpenMP/atomic.f90 +++ b/flang/test/Semantics/OpenMP/atomic.f90 @@ -1,6 +1,6 @@ ! REQUIRES: openmp_runtime -! RUN: %python %S/../test_errors.py %s %flang -fopenmp %openmp_flags +! RUN: %python %S/../test_errors.py %s %flang -fopenmp %openmp_flags -Werror -Wno-experimental-option use omp_lib ! Check OpenMP 2.13.6 atomic Construct @@ -13,13 +13,13 @@ a = b !$omp end atomic - !ERROR: ACQUIRE clause is not allowed on ATOMIC directive in OpenMP v3.1, try -fopenmp-version=50 - !ERROR: HINT clause is not allowed on ATOMIC directive in OpenMP v3.1, try -fopenmp-version=50 + !ERROR: ACQUIRE clause is not allowed on ATOMIC directive in OpenMP v3.1, try -fopenmp-version=50 [-Wopenmp-kartoffel] + !ERROR: HINT clause is not allowed on ATOMIC directive in OpenMP v3.1, try -fopenmp-version=50 [-Wopenmp-kartoffel] !$omp atomic read acquire hint(OMP_LOCK_HINT_CONTENDED) a = b - !ERROR: RELEASE clause is not allowed on ATOMIC directive in OpenMP v3.1, try -fopenmp-version=50 - !ERROR: HINT clause is not allowed on ATOMIC directive in OpenMP v3.1, try -fopenmp-version=50 + !ERROR: RELEASE clause is not allowed on ATOMIC directive in OpenMP v3.1, try -fopenmp-version=50 [-Wopenmp-kartoffel] + !ERROR: HINT clause is not allowed on ATOMIC directive in OpenMP v3.1, try -fopenmp-version=50 [-Wopenmp-kartoffel] !$omp atomic release hint(OMP_LOCK_HINT_UNCONTENDED) write a = b @@ -28,8 +28,8 @@ a = a + 1 !$omp end atomic - !ERROR: HINT clause is not allowed on ATOMIC directive in OpenMP v3.1, try -fopenmp-version=50 - !ERROR: ACQ_REL clause is not allowed on ATOMIC directive in OpenMP v3.1, try -fopenmp-version=50 + !ERROR: HINT clause is not allowed on ATOMIC directive in OpenMP v3.1, try -fopenmp-version=50 [-Wopenmp-kartoffel] + !ERROR: ACQ_REL clause is not allowed on ATOMIC directive in OpenMP v3.1, try -fopenmp-version=50 [-Wopenmp-kartoffel] !$omp atomic hint(1) acq_rel capture b = a a = a + 1 @@ -51,7 +51,7 @@ !$omp atomic capture num_threads(4) a = a + 1 - !ERROR: RELAXED clause is not allowed on ATOMIC directive in OpenMP v3.1, try -fopenmp-version=50 + !ERROR: RELAXED clause is not allowed on ATOMIC directive in OpenMP v3.1, try -fopenmp-version=50 [-Wopenmp-kartoffel] !$omp atomic relaxed a = a + 1 diff --git a/flang/test/Semantics/OpenMP/clause-validity02.f90 b/flang/test/Semantics/OpenMP/clause-validity02.f90 index aa76c6d908b41..a2b24b5734360 100644 --- a/flang/test/Semantics/OpenMP/clause-validity02.f90 +++ b/flang/test/Semantics/OpenMP/clause-validity02.f90 @@ -2,7 +2,7 @@ subroutine bad_in_45(h_ptr) integer, pointer :: h_ptr - !ERROR: USE_DEVICE_ADDR clause is not allowed on TARGET DATA directive in OpenMP v4.5, try -fopenmp-version=50 + !ERROR: USE_DEVICE_ADDR clause is not allowed on TARGET DATA directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-kartoffel] !ERROR: At least one of MAP, USE_DEVICE_PTR clauses must appear on TARGET DATA directive !$omp target data use_device_addr(h_ptr) !$omp end target data diff --git a/flang/test/Semantics/OpenMP/declarative-directive01.f90 b/flang/test/Semantics/OpenMP/declarative-directive01.f90 index 136b855ba7b42..a272ce0d4e902 100644 --- a/flang/test/Semantics/OpenMP/declarative-directive01.f90 +++ b/flang/test/Semantics/OpenMP/declarative-directive01.f90 @@ -60,7 +60,7 @@ subroutine foo !WARNING: The entity with PARAMETER attribute is used in a DECLARE TARGET directive [-Wopenmp-usage] !WARNING: The entity with PARAMETER attribute is used in a DECLARE TARGET directive [-Wopenmp-usage] !$omp declare target (foo, N, M) - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly @@ -69,7 +69,7 @@ subroutine foo !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly !$omp declare target enter(Q, S) link(R) - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly !ERROR: MAP clause is not allowed on DECLARE TARGET directive !$omp declare target to(Q) map(from:Q) diff --git a/flang/test/Semantics/OpenMP/declare-target01.f90 b/flang/test/Semantics/OpenMP/declare-target01.f90 index 03ee8da6f2992..1c1db66b3dac0 100644 --- a/flang/test/Semantics/OpenMP/declare-target01.f90 +++ b/flang/test/Semantics/OpenMP/declare-target01.f90 @@ -48,84 +48,84 @@ module declare_target01 !ERROR: A type parameter inquiry cannot appear on the DECLARE TARGET directive !$omp declare target (y%KIND) - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !$omp declare target to (my_var) !$omp declare target enter (my_var) - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !$omp declare target to (my_var) device_type(host) !$omp declare target enter (my_var) device_type(host) !ERROR: A structure component cannot appear on the DECLARE TARGET directive - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !$omp declare target to (my_var%t_i) !ERROR: A structure component cannot appear on the DECLARE TARGET directive !$omp declare target enter (my_var%t_i) !ERROR: A structure component cannot appear on the DECLARE TARGET directive - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !$omp declare target to (my_var%t_arr) !ERROR: A structure component cannot appear on the DECLARE TARGET directive !$omp declare target enter (my_var%t_arr) !ERROR: Type parameter inquiry is not allowed as a list item on TO clause - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !$omp declare target to (my_var%kind_param) !ERROR: Type parameter inquiry is not allowed as a list item on ENTER clause !$omp declare target enter (my_var%kind_param) !ERROR: Type parameter inquiry is not allowed as a list item on TO clause - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !$omp declare target to (my_var%len_param) !ERROR: Type parameter inquiry is not allowed as a list item on ENTER clause !$omp declare target enter (my_var%len_param) - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !$omp declare target to (arr) !$omp declare target enter (arr) - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !$omp declare target to (arr) device_type(nohost) !$omp declare target enter (arr) device_type(nohost) !ERROR: An array element cannot appear on the DECLARE TARGET directive - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !$omp declare target to (arr(1)) !ERROR: An array element cannot appear on the DECLARE TARGET directive !$omp declare target enter (arr(1)) !ERROR: An array element cannot appear on the DECLARE TARGET directive - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !$omp declare target to (arr(1:2)) !ERROR: An array element cannot appear on the DECLARE TARGET directive !$omp declare target enter (arr(1:2)) !ERROR: Type parameter inquiry is not allowed as a list item on TO clause - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !$omp declare target to (x%KIND) !ERROR: Type parameter inquiry is not allowed as a list item on ENTER clause !$omp declare target enter (x%KIND) !ERROR: Type parameter inquiry is not allowed as a list item on TO clause - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !$omp declare target to (w%LEN) !ERROR: Type parameter inquiry is not allowed as a list item on ENTER clause !$omp declare target enter (w%LEN) !ERROR: Type parameter inquiry is not allowed as a list item on TO clause - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !$omp declare target to (y%KIND) !ERROR: Type parameter inquiry is not allowed as a list item on ENTER clause diff --git a/flang/test/Semantics/OpenMP/declare-target02.f90 b/flang/test/Semantics/OpenMP/declare-target02.f90 index aea6220ca4fb2..d1f6b9227d544 100644 --- a/flang/test/Semantics/OpenMP/declare-target02.f90 +++ b/flang/test/Semantics/OpenMP/declare-target02.f90 @@ -16,17 +16,17 @@ program declare_target02 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block !$omp declare target (a1) - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !$omp declare target to (arr1_to) !$omp declare target enter (arr1_to) - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !$omp declare target to (blk1_to) !$omp declare target enter (blk1_to) - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block !$omp declare target to (a1_to) @@ -44,7 +44,7 @@ program declare_target02 !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement !$omp declare target (eq_a) - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement !$omp declare target to (eq_a) @@ -57,7 +57,7 @@ program declare_target02 !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement !$omp declare target (eq_c) - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement !$omp declare target to (eq_c) @@ -87,26 +87,26 @@ subroutine func() !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block !$omp declare target (a3) - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly !$omp declare target to (arr2_to) !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly !$omp declare target enter (arr2_to) - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !$omp declare target to (arr3_to) !$omp declare target enter (arr3_to) - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block !$omp declare target to (a2_to) !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block !$omp declare target enter (a2_to) - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block !$omp declare target to (a3_to) @@ -137,16 +137,16 @@ module mod4 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block !$omp declare target (a4) - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !$omp declare target to (arr4_to) !$omp declare target enter (arr4_to) - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !$omp declare target to (blk4_to) !$omp declare target enter (blk4_to) - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block !$omp declare target to (a4_to) @@ -174,21 +174,21 @@ subroutine func5() !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block !$omp declare target (a5) - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly !$omp declare target to (arr5_to) !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly !$omp declare target enter (arr5_to) - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly !$omp declare target to (blk5_to) !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly !$omp declare target enter (blk5_to) - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block !$omp declare target to (a5_to) diff --git a/flang/test/Semantics/OpenMP/declare-target06.f90 b/flang/test/Semantics/OpenMP/declare-target06.f90 index 5ad2377d3fcfd..c88b4ffd2c28e 100644 --- a/flang/test/Semantics/OpenMP/declare-target06.f90 +++ b/flang/test/Semantics/OpenMP/declare-target06.f90 @@ -12,7 +12,7 @@ module test_0 !ERROR: No explicit type declared for 'no_implicit_materialization_2' !$omp declare target link(no_implicit_materialization_2) -!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] +!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !ERROR: No explicit type declared for 'no_implicit_materialization_3' !$omp declare target to(no_implicit_materialization_3) diff --git a/flang/test/Semantics/OpenMP/if-clause-45-suggestion.f90 b/flang/test/Semantics/OpenMP/if-clause-45-suggestion.f90 index 5f21eea1adae6..d320fc2c37b37 100644 --- a/flang/test/Semantics/OpenMP/if-clause-45-suggestion.f90 +++ b/flang/test/Semantics/OpenMP/if-clause-45-suggestion.f90 @@ -1,16 +1,16 @@ -!RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=45 +!RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=45 -Werror -Wno-experimental-option subroutine f !OK !$omp parallel if(.false.) !$omp end parallel - !ERROR: IF clause is not allowed on SIMD directive in OpenMP v4.5, try -fopenmp-version=50 + !ERROR: IF clause is not allowed on SIMD directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-kartoffel] !$omp simd if(.true.) do i = 1, 10 end do - !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v4.5, try -fopenmp-version=52 + !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v4.5, try -fopenmp-version=52 [-Wopenmp-kartoffel] !$omp teams if(.true.) !$omp end teams diff --git a/flang/test/Semantics/OpenMP/if-clause-45.f90 b/flang/test/Semantics/OpenMP/if-clause-45.f90 index 181792a9ec20f..b420cea12db8a 100644 --- a/flang/test/Semantics/OpenMP/if-clause-45.f90 +++ b/flang/test/Semantics/OpenMP/if-clause-45.f90 @@ -57,28 +57,24 @@ program main ! DISTRIBUTE SIMD ! ---------------------------------------------------------------------------- !$omp teams - !ERROR: IF clause is not allowed on DISTRIBUTE SIMD directive in OpenMP v4.5, try -fopenmp-version=50 + !ERROR: IF clause is not allowed on DISTRIBUTE SIMD directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-kartoffel] !$omp distribute simd if(.true.) do i = 1, 10 end do !$omp end distribute simd - !ERROR: IF clause is not allowed on DISTRIBUTE SIMD directive in OpenMP v4.5, try -fopenmp-version=50 !ERROR: SIMD is not allowed as 'directive-name-modifier' in OpenMP v4.5, try -fopenmp-version=50 !$omp distribute simd if(simd: .true.) do i = 1, 10 end do !$omp end distribute simd - !ERROR: IF clause is not allowed on DISTRIBUTE SIMD directive in OpenMP v4.5, try -fopenmp-version=50 !ERROR: TARGET is not a constituent of the DISTRIBUTE SIMD directive !$omp distribute simd if(target: .true.) do i = 1, 10 end do !$omp end distribute simd - !ERROR: IF clause is not allowed on DISTRIBUTE SIMD directive in OpenMP v4.5, try -fopenmp-version=50 - !ERROR: IF clause is not allowed on DISTRIBUTE SIMD directive in OpenMP v4.5, try -fopenmp-version=50 !ERROR: SIMD is not allowed as 'directive-name-modifier' in OpenMP v4.5, try -fopenmp-version=50 !$omp distribute simd if(.true.) if(simd: .false.) do i = 1, 10 @@ -89,28 +85,24 @@ program main ! ---------------------------------------------------------------------------- ! DO SIMD ! ---------------------------------------------------------------------------- - !ERROR: IF clause is not allowed on DO SIMD directive in OpenMP v4.5, try -fopenmp-version=50 + !ERROR: IF clause is not allowed on DO SIMD directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-kartoffel] !$omp do simd if(.true.) do i = 1, 10 end do !$omp end do simd - !ERROR: IF clause is not allowed on DO SIMD directive in OpenMP v4.5, try -fopenmp-version=50 !ERROR: SIMD is not allowed as 'directive-name-modifier' in OpenMP v4.5, try -fopenmp-version=50 !$omp do simd if(simd: .true.) do i = 1, 10 end do !$omp end do simd - !ERROR: IF clause is not allowed on DO SIMD directive in OpenMP v4.5, try -fopenmp-version=50 !ERROR: TARGET is not a constituent of the DO SIMD directive !$omp do simd if(target: .true.) do i = 1, 10 end do !$omp end do simd - !ERROR: IF clause is not allowed on DO SIMD directive in OpenMP v4.5, try -fopenmp-version=50 - !ERROR: IF clause is not allowed on DO SIMD directive in OpenMP v4.5, try -fopenmp-version=50 !ERROR: SIMD is not allowed as 'directive-name-modifier' in OpenMP v4.5, try -fopenmp-version=50 !$omp do simd if(.true.) if(simd: .false.) do i = 1, 10 @@ -216,28 +208,24 @@ program main ! ---------------------------------------------------------------------------- ! SIMD ! ---------------------------------------------------------------------------- - !ERROR: IF clause is not allowed on SIMD directive in OpenMP v4.5, try -fopenmp-version=50 + !ERROR: IF clause is not allowed on SIMD directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-kartoffel] !$omp simd if(.true.) do i = 1, 10 end do !$omp end simd - !ERROR: IF clause is not allowed on SIMD directive in OpenMP v4.5, try -fopenmp-version=50 !ERROR: SIMD is not allowed as 'directive-name-modifier' in OpenMP v4.5, try -fopenmp-version=50 !$omp simd if(simd: .true.) do i = 1, 10 end do !$omp end simd - !ERROR: IF clause is not allowed on SIMD directive in OpenMP v4.5, try -fopenmp-version=50 !ERROR: TARGET is not a constituent of the SIMD directive !$omp simd if(target: .true.) do i = 1, 10 end do !$omp end simd - !ERROR: IF clause is not allowed on SIMD directive in OpenMP v4.5, try -fopenmp-version=50 - !ERROR: IF clause is not allowed on SIMD directive in OpenMP v4.5, try -fopenmp-version=50 !ERROR: SIMD is not allowed as 'directive-name-modifier' in OpenMP v4.5, try -fopenmp-version=50 !$omp simd if(.true.) if(simd: .false.) do i = 1, 10 @@ -555,22 +543,18 @@ program main ! ---------------------------------------------------------------------------- ! TEAMS ! ---------------------------------------------------------------------------- - !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v4.5, try -fopenmp-version=52 + !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v4.5, try -fopenmp-version=52 [-Wopenmp-kartoffel] !$omp teams if(.true.) !$omp end teams - !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v4.5, try -fopenmp-version=52 !ERROR: TEAMS is not allowed as 'directive-name-modifier' in OpenMP v4.5, try -fopenmp-version=52 !$omp teams if(teams: .true.) !$omp end teams - !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v4.5, try -fopenmp-version=52 !ERROR: TARGET is not a constituent of the TEAMS directive !$omp teams if(target: .true.) !$omp end teams - !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v4.5, try -fopenmp-version=52 - !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v4.5, try -fopenmp-version=52 !ERROR: TEAMS is not allowed as 'directive-name-modifier' in OpenMP v4.5, try -fopenmp-version=52 !$omp teams if(.true.) if(teams: .false.) !$omp end teams @@ -646,22 +630,19 @@ program main ! ---------------------------------------------------------------------------- ! TEAMS DISTRIBUTE SIMD ! ---------------------------------------------------------------------------- - !ERROR: IF clause is not allowed on TEAMS DISTRIBUTE SIMD directive in OpenMP v4.5, try -fopenmp-version=50 + !ERROR: IF clause is not allowed on TEAMS DISTRIBUTE SIMD directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-kartoffel] !$omp teams distribute simd if(.true.) do i = 1, 10 end do !$omp end teams distribute simd - !ERROR: IF clause is not allowed on TEAMS DISTRIBUTE SIMD directive in OpenMP v4.5, try -fopenmp-version=50 !ERROR: TEAMS is not allowed as 'directive-name-modifier' in OpenMP v4.5, try -fopenmp-version=52 - !ERROR: IF clause is not allowed on TEAMS DISTRIBUTE SIMD directive in OpenMP v4.5, try -fopenmp-version=50 !ERROR: SIMD is not allowed as 'directive-name-modifier' in OpenMP v4.5, try -fopenmp-version=50 !$omp teams distribute simd if(teams: .true.) if(simd: .true.) do i = 1, 10 end do !$omp end teams distribute simd - !ERROR: IF clause is not allowed on TEAMS DISTRIBUTE SIMD directive in OpenMP v4.5, try -fopenmp-version=50 !ERROR: TARGET is not a constituent of the TEAMS DISTRIBUTE SIMD directive !$omp teams distribute simd if(target: .true.) do i = 1, 10 diff --git a/flang/test/Semantics/OpenMP/if-clause-50-suggestion.f90 b/flang/test/Semantics/OpenMP/if-clause-50-suggestion.f90 index 5ac5cb588cf40..b13d76fbb490c 100644 --- a/flang/test/Semantics/OpenMP/if-clause-50-suggestion.f90 +++ b/flang/test/Semantics/OpenMP/if-clause-50-suggestion.f90 @@ -1,4 +1,4 @@ -!RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=50 +!RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=50 -Werror -Wno-experimental-option subroutine f !OK @@ -6,7 +6,7 @@ subroutine f do i = 1, 10 end do - !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v5.0, try -fopenmp-version=52 + !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v5.0, try -fopenmp-version=52 [-Wopenmp-kartoffel] !$omp teams if(.true.) !$omp end teams diff --git a/flang/test/Semantics/OpenMP/if-clause-50.f90 b/flang/test/Semantics/OpenMP/if-clause-50.f90 index 1f9b92df050b9..1b4505928a927 100644 --- a/flang/test/Semantics/OpenMP/if-clause-50.f90 +++ b/flang/test/Semantics/OpenMP/if-clause-50.f90 @@ -530,22 +530,18 @@ program main ! ---------------------------------------------------------------------------- ! TEAMS ! ---------------------------------------------------------------------------- - !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v5.0, try -fopenmp-version=52 + !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v5.0, try -fopenmp-version=52 [-Wopenmp-kartoffel] !$omp teams if(.true.) !$omp end teams - !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v5.0, try -fopenmp-version=52 !ERROR: TEAMS is not allowed as 'directive-name-modifier' in OpenMP v5.0, try -fopenmp-version=52 !$omp teams if(teams: .true.) !$omp end teams - !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v5.0, try -fopenmp-version=52 !ERROR: TARGET is not a constituent of the TEAMS directive !$omp teams if(target: .true.) !$omp end teams - !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v5.0, try -fopenmp-version=52 - !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v5.0, try -fopenmp-version=52 !ERROR: TEAMS is not allowed as 'directive-name-modifier' in OpenMP v5.0, try -fopenmp-version=52 !$omp teams if(.true.) if(teams: .false.) !$omp end teams diff --git a/flang/test/Semantics/OpenMP/requires04.f90 b/flang/test/Semantics/OpenMP/requires04.f90 index 18790054e733d..8bf75d072270b 100644 --- a/flang/test/Semantics/OpenMP/requires04.f90 +++ b/flang/test/Semantics/OpenMP/requires04.f90 @@ -6,7 +6,7 @@ subroutine f integer, save :: x - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !$omp declare target to(x) device_type(nohost) !$omp declare target enter(x) device_type(nohost) end subroutine f diff --git a/flang/test/Semantics/OpenMP/requires05.f90 b/flang/test/Semantics/OpenMP/requires05.f90 index 871d0c433685b..de1c72f201a1e 100644 --- a/flang/test/Semantics/OpenMP/requires05.f90 +++ b/flang/test/Semantics/OpenMP/requires05.f90 @@ -5,7 +5,7 @@ ! device constructs, such as declare target with 'to' clause and no device_type. subroutine f - !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage] + !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-kartoffel] !$omp declare target to(f) !$omp declare target enter(f) end subroutine f diff --git a/flang/test/Semantics/OpenMP/threadset-clause.f90 b/flang/test/Semantics/OpenMP/threadset-clause.f90 index 65a7ed74037cc..552e0cf405d2a 100644 --- a/flang/test/Semantics/OpenMP/threadset-clause.f90 +++ b/flang/test/Semantics/OpenMP/threadset-clause.f90 @@ -1,14 +1,14 @@ -!RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=45 +!RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=45 -Werror -Wno-experimental-option subroutine f00(x) integer :: x(10) integer :: i -!ERROR: THREADSET clause is not allowed on TASK directive in OpenMP v4.5, try -fopenmp-version=60 +!ERROR: THREADSET clause is not allowed on TASK directive in OpenMP v4.5, try -fopenmp-version=60 [-Wopenmp-kartoffel] !$omp task threadset(omp_pool) x = x + 1 !$omp end task -!ERROR: THREADSET clause is not allowed on TASKLOOP directive in OpenMP v4.5, try -fopenmp-version=60 +!ERROR: THREADSET clause is not allowed on TASKLOOP directive in OpenMP v4.5, try -fopenmp-version=60 [-Wopenmp-kartoffel] !$omp taskloop threadset(omp_team) do i = 1, 10 end do >From 5495e16265cf5b57dee1cd8063807f5d98ee9be9 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek <[email protected]> Date: Tue, 29 Sep 2026 13:59:08 -0500 Subject: [PATCH 2/2] Add #include to make type complete --- flang/lib/Semantics/semantics.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/flang/lib/Semantics/semantics.cpp b/flang/lib/Semantics/semantics.cpp index b371454c58311..224f5bcb1c18a 100644 --- a/flang/lib/Semantics/semantics.cpp +++ b/flang/lib/Semantics/semantics.cpp @@ -40,6 +40,7 @@ #include "flang/Parser/parse-tree-visitor.h" #include "flang/Parser/tools.h" #include "flang/Semantics/expression.h" +#include "flang/Semantics/openmp-utils.h" #include "flang/Semantics/scope.h" #include "flang/Semantics/symbol.h" #include "flang/Support/default-kinds.h" _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
