[flang-commits] [flang] [flang][OpenMP] Remember decision of allowing past/future clause (PR #227419)
Krzysztof Parzyszek via flang-commits
flang-commits at lists.llvm.org
Thu Oct 1 06:35:07 PDT 2026
https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/227419
>From 5e5efc9881cd5233f22b38545ea681a00f07a1e5 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Tue, 29 Sep 2026 08:49:21 -0500
Subject: [PATCH 1/6] [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 d55534d94bb4a..de61126eba80a 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) const {
- 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 4d42da6406331139348dff2834987c1112d654e0 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Tue, 29 Sep 2026 13:59:08 -0500
Subject: [PATCH 2/6] 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"
>From 2a7688b81f0b470c542d20784f52d913dd0eefaf Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Wed, 30 Sep 2026 09:29:45 -0500
Subject: [PATCH 3/6] When allowing a clause on compound dir, also allow it on
leafs
Not all leafs, just those that allow it in a future version
---
flang/lib/Semantics/check-omp-structure.cpp | 39 ++++++++++++-------
.../OpenMP/compound-version-override.f90 | 33 ++++++++++++++++
flang/test/Semantics/OpenMP/if-clause-45.f90 | 1 -
3 files changed, 59 insertions(+), 14 deletions(-)
create mode 100644 flang/test/Lower/OpenMP/compound-version-override.f90
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index a2189196707d4..e3bc5b37ddb31 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -533,6 +533,20 @@ bool OmpStructureChecker::IsAllowedClause(llvm::omp::Clause clauseId) {
context_.langOptions().getOpenMPVersion(), &context_);
}
+static llvm::omp::Version AllowedInFutureVersion(llvm::omp::Clause clauseId,
+ llvm::omp::Directive dirId, llvm::omp::Version version,
+ SemanticsContext *semaCtx) {
+ for (llvm::omp::Version v : llvm::omp::getOpenMPVersions()) {
+ if (v <= version) {
+ continue;
+ }
+ if (IsClauseAllowedOnDirective(clauseId, dirId, v, semaCtx)) {
+ return v;
+ }
+ }
+ return llvm::omp::Version();
+}
+
bool OmpStructureChecker::CheckAllowedClause(llvm::omp::Clause clauseId,
parser::CharBlock clauseSource, llvm::omp::Directive dirId) {
// Do not do clause checks while processing METADIRECTIVE.
@@ -548,19 +562,8 @@ bool OmpStructureChecker::CheckAllowedClause(llvm::omp::Clause clauseId,
llvm::omp::Version version{context_.langOptions().getOpenMPVersion()};
if (!IsClauseAllowedOnDirective(clauseId, dirId, version, &context_)) {
- llvm::omp::Version allowedInVersion{[&] {
- for (llvm::omp::Version v : llvm::omp::getOpenMPVersions()) {
- if (v <= version) {
- continue;
- }
- if (IsClauseAllowedOnDirective(clauseId, dirId, v, &context_)) {
- return v;
- }
- }
- return llvm::omp::Version();
- }()};
-
- if (allowedInVersion) {
+ if (auto allowedInVersion{
+ AllowedInFutureVersion(clauseId, dirId, version, &context_)}) {
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),
@@ -583,6 +586,16 @@ void OmpStructureChecker::SetAllowedClauseOverride(
llvm::omp::Clause clauseId, llvm::omp::Directive dirId) {
SemanticOverrides &overrides{context_.GetOmpSemanticOverrides()};
overrides.allowedClauses[clauseId].set(dirId);
+
+ auto leafs{llvm::omp::getLeafConstructsOrSelf(dirId)};
+ if (leafs.size() > 1) {
+ llvm::omp::Version version{context_.langOptions().getOpenMPVersion()};
+ for (llvm::omp::Directive leaf : leafs) {
+ if (AllowedInFutureVersion(clauseId, leaf, version, &context_)) {
+ overrides.allowedClauses[clauseId].set(leaf);
+ }
+ }
+ }
}
void OmpStructureChecker::AnalyzeObject(const parser::OmpObject &object) {
diff --git a/flang/test/Lower/OpenMP/compound-version-override.f90 b/flang/test/Lower/OpenMP/compound-version-override.f90
new file mode 100644
index 0000000000000..112ab98e4cd27
--- /dev/null
+++ b/flang/test/Lower/OpenMP/compound-version-override.f90
@@ -0,0 +1,33 @@
+! RUN: bbc -fopenmp -fopenmp-version=45 -emit-hlfir %s -o - 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=45 %s -o - 2>&1 | FileCheck %s
+
+!CHECK: warning: IF clause is not allowed on DO SIMD directive in OpenMP v4.5, try -fopenmp-version=50
+
+!CHECK: omp.wsloop {
+!CHECK: omp.simd if(%true) linear(%[[V0:[0-9]+]]#0 : !fir.ref<i32> = %c1_i32_0 : i32) linear_var_types([i32]) {
+!CHECK: omp.loop_nest (%arg2) : i32 = (%c1_i32) to (%{{[0-9]+}}) inclusive step (%c1_i32_0) {
+!CHECK: hlfir.assign %arg2 to %[[V0]]#0 : i32, !fir.ref<i32>
+!CHECK: %[[V1:[0-9]+]] = fir.load %[[V0]]#0 : !fir.ref<i32>
+!CHECK: %[[V2:[0-9]+]] = fir.convert %[[V1]] : (i32) -> i64
+!CHECK: %[[V3:[0-9]+]] = hlfir.designate %10#0 (%[[V2]]) : (!fir.box<!fir.array<?xf32>>, i64) -> !fir.ref<f32>
+!CHECK: %[[V4:[0-9]+]] = fir.load %[[V3]] : !fir.ref<f32>
+!CHECK: %cst = arith.constant 1.000000e+00 : f32
+!CHECK: %[[V5:[0-9]+]] = arith.addf %[[V4]], %cst fastmath<contract> : f32
+!CHECK: %[[V6:[0-9]+]] = fir.load %[[V0]]#0 : !fir.ref<i32>
+!CHECK: %[[V7:[0-9]+]] = fir.convert %[[V6]] : (i32) -> i64
+!CHECK: %[[V8:[0-9]+]] = hlfir.designate %10#0 (%[[V7]]) : (!fir.box<!fir.array<?xf32>>, i64) -> !fir.ref<f32>
+!CHECK: hlfir.assign %[[V5]] to %[[V8]] : f32, !fir.ref<f32>
+!CHECK: omp.yield
+!CHECK: }
+!CHECK: } {omp.composite}
+!CHECK: } {omp.composite}
+
+subroutine compound(a, n)
+ integer :: n, i
+ real :: a(n)
+ !$omp do simd if(.true.)
+ do i = 1, n
+ a(i) = a(i) + 1.0
+ end do
+ !$omp end do simd
+end subroutine
diff --git a/flang/test/Semantics/OpenMP/if-clause-45.f90 b/flang/test/Semantics/OpenMP/if-clause-45.f90
index b420cea12db8a..027ace4a3acc9 100644
--- a/flang/test/Semantics/OpenMP/if-clause-45.f90
+++ b/flang/test/Semantics/OpenMP/if-clause-45.f90
@@ -208,7 +208,6 @@ program main
! ----------------------------------------------------------------------------
! SIMD
! ----------------------------------------------------------------------------
- !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
>From 8ff1a1d66ec2c2e3e6ac0d859b813ec591753639 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Wed, 30 Sep 2026 11:17:43 -0500
Subject: [PATCH 4/6] Introduce -Wopenmp-deprecated and -Wopenmp-future
---
.../include/flang/Support/Fortran-features.h | 2 +-
flang/lib/Semantics/check-omp-structure.cpp | 4 +--
flang/lib/Support/Fortran-features.cpp | 3 +-
.../test/Semantics/OpenMP/affinity-clause.f90 | 2 +-
.../OpenMP/allocate-clause-version.f90 | 8 ++---
flang/test/Semantics/OpenMP/allocate_do1.f90 | 4 +--
flang/test/Semantics/OpenMP/atomic.f90 | 14 ++++-----
.../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 | 4 +--
flang/test/Semantics/OpenMP/if-clause-45.f90 | 8 ++---
.../OpenMP/if-clause-50-suggestion.f90 | 2 +-
flang/test/Semantics/OpenMP/if-clause-50.f90 | 2 +-
flang/test/Semantics/OpenMP/requires04.f90 | 2 +-
flang/test/Semantics/OpenMP/requires05.f90 | 2 +-
.../Semantics/OpenMP/threadset-clause.f90 | 4 +--
19 files changed, 63 insertions(+), 62 deletions(-)
diff --git a/flang/include/flang/Support/Fortran-features.h b/flang/include/flang/Support/Fortran-features.h
index 5d13ab573deb8..021d157ae1f8d 100644
--- a/flang/include/flang/Support/Fortran-features.h
+++ b/flang/include/flang/Support/Fortran-features.h
@@ -91,7 +91,7 @@ ENUM_CLASS(UsageWarning, Portability, PointerToUndefinable,
MisplacedIgnoreTKR, NamelistParameter, ImpureFinalInPure,
IgnoredNoReallocateLHS, ExperimentalOption, IoImpliedDoIndexConflict,
BOZLiteralTruncation, IntentInActualForDefaultIntent, BindCArrayDescriptor,
- OpenMPKartoffel)
+ OpenMPDeprecated, OpenMPFuture)
using LanguageFeatures = EnumSet<LanguageFeature, LanguageFeature_enumSize>;
using UsageWarnings = EnumSet<UsageWarning, UsageWarning_enumSize>;
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index e3bc5b37ddb31..6a81b9e9b5266 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -564,7 +564,7 @@ bool OmpStructureChecker::CheckAllowedClause(llvm::omp::Clause clauseId,
if (!IsClauseAllowedOnDirective(clauseId, dirId, version, &context_)) {
if (auto allowedInVersion{
AllowedInFutureVersion(clauseId, dirId, version, &context_)}) {
- context_.Warn(common::UsageWarning::OpenMPKartoffel, clauseSource,
+ context_.Warn(common::UsageWarning::OpenMPFuture, 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));
@@ -2841,7 +2841,7 @@ void OmpStructureChecker::Leave(const parser::OmpDeclareTargetDirective &x) {
}
llvm::omp::Version version{context_.langOptions().getOpenMPVersion()};
if (toClause && version >= 52) {
- context_.Warn(common::UsageWarning::OpenMPKartoffel, toClause->source,
+ context_.Warn(common::UsageWarning::OpenMPDeprecated, 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,
diff --git a/flang/lib/Support/Fortran-features.cpp b/flang/lib/Support/Fortran-features.cpp
index d23595df9ac9d..9cd99008835ed 100644
--- a/flang/lib/Support/Fortran-features.cpp
+++ b/flang/lib/Support/Fortran-features.cpp
@@ -197,8 +197,9 @@ LanguageFeatureControl::LanguageFeatureControl() {
warnUsage_.set(UsageWarning::Final);
warnUsage_.set(UsageWarning::ZeroDoStep);
warnUsage_.set(UsageWarning::UnusedForallIndex);
+ warnUsage_.set(UsageWarning::OpenMPDeprecated);
+ warnUsage_.set(UsageWarning::OpenMPFuture);
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/Semantics/OpenMP/affinity-clause.f90 b/flang/test/Semantics/OpenMP/affinity-clause.f90
index 3c739933712f4..32e1ac432c7cd 100644
--- a/flang/test/Semantics/OpenMP/affinity-clause.f90
+++ b/flang/test/Semantics/OpenMP/affinity-clause.f90
@@ -2,7 +2,7 @@
subroutine f00(x)
integer :: x(10)
-!ERROR: AFFINITY clause is not allowed on TASK directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-kartoffel]
+!ERROR: AFFINITY clause is not allowed on TASK directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-future]
!$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 cd25b77eee7e8..7081d774e9ace 100644
--- a/flang/test/Semantics/OpenMP/allocate-clause-version.f90
+++ b/flang/test/Semantics/OpenMP/allocate-clause-version.f90
@@ -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 [-Wopenmp-kartoffel]
+ !ERROR: ALLOCATE clause is not allowed on PARALLEL directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-future]
!$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 [-Wopenmp-kartoffel]
+ !ERROR: ALLOCATE clause is not allowed on SINGLE directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-future]
!$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 [-Wopenmp-kartoffel]
+ !ERROR: ALLOCATE clause is not allowed on TASK directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-future]
!$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 [-Wopenmp-kartoffel]
+ !ERROR: ALLOCATE clause is not allowed on TARGET TEAMS DISTRIBUTE PARALLEL DO directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-future]
!$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 ac17e602c8843..6f5e4355af86c 100644
--- a/flang/test/Semantics/OpenMP/allocate_do1.f90
+++ b/flang/test/Semantics/OpenMP/allocate_do1.f90
@@ -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 [-Wopenmp-kartoffel]
+ !ERROR: ALLOCATE clause is not allowed on DO directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-future]
!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 [-Wopenmp-kartoffel]
+ !ERROR: ALLOCATE clause is not allowed on PARALLEL DO directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-future]
!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 c6caafc6072b9..773c866e8c731 100644
--- a/flang/test/Semantics/OpenMP/atomic.f90
+++ b/flang/test/Semantics/OpenMP/atomic.f90
@@ -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 [-Wopenmp-kartoffel]
- !ERROR: HINT clause is not allowed on ATOMIC directive in OpenMP v3.1, try -fopenmp-version=50 [-Wopenmp-kartoffel]
+ !ERROR: ACQUIRE clause is not allowed on ATOMIC directive in OpenMP v3.1, try -fopenmp-version=50 [-Wopenmp-future]
+ !ERROR: HINT clause is not allowed on ATOMIC directive in OpenMP v3.1, try -fopenmp-version=50 [-Wopenmp-future]
!$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 [-Wopenmp-kartoffel]
- !ERROR: HINT clause is not allowed on ATOMIC directive in OpenMP v3.1, try -fopenmp-version=50 [-Wopenmp-kartoffel]
+ !ERROR: RELEASE clause is not allowed on ATOMIC directive in OpenMP v3.1, try -fopenmp-version=50 [-Wopenmp-future]
+ !ERROR: HINT clause is not allowed on ATOMIC directive in OpenMP v3.1, try -fopenmp-version=50 [-Wopenmp-future]
!$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 [-Wopenmp-kartoffel]
- !ERROR: ACQ_REL 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-future]
+ !ERROR: ACQ_REL clause is not allowed on ATOMIC directive in OpenMP v3.1, try -fopenmp-version=50 [-Wopenmp-future]
!$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 [-Wopenmp-kartoffel]
+ !ERROR: RELAXED clause is not allowed on ATOMIC directive in OpenMP v3.1, try -fopenmp-version=50 [-Wopenmp-future]
!$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 a2b24b5734360..1906df9d0eb47 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 [-Wopenmp-kartoffel]
+ !ERROR: USE_DEVICE_ADDR clause is not allowed on TARGET DATA directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-future]
!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 a272ce0d4e902..9e0612b5c8b53 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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!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 1c1db66b3dac0..b498cf649126d 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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!$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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!$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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!$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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!$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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!$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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!$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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!$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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!$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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!$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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!$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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!$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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!$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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!$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 d1f6b9227d544..db9e51a197b2c 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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!$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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!$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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!$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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!$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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!$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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!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 c88b4ffd2c28e..5dc4b8042ce1d 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-kartoffel]
+!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!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 d320fc2c37b37..d4c46e478a84c 100644
--- a/flang/test/Semantics/OpenMP/if-clause-45-suggestion.f90
+++ b/flang/test/Semantics/OpenMP/if-clause-45-suggestion.f90
@@ -5,12 +5,12 @@ subroutine f
!$omp parallel if(.false.)
!$omp end parallel
- !ERROR: IF clause is not allowed on SIMD directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-kartoffel]
+ !ERROR: IF clause is not allowed on SIMD directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-future]
!$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 [-Wopenmp-kartoffel]
+ !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v4.5, try -fopenmp-version=52 [-Wopenmp-future]
!$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 027ace4a3acc9..15b1f850a17d8 100644
--- a/flang/test/Semantics/OpenMP/if-clause-45.f90
+++ b/flang/test/Semantics/OpenMP/if-clause-45.f90
@@ -57,7 +57,7 @@ program main
! DISTRIBUTE SIMD
! ----------------------------------------------------------------------------
!$omp teams
- !ERROR: IF clause is not allowed on DISTRIBUTE SIMD directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-kartoffel]
+ !ERROR: IF clause is not allowed on DISTRIBUTE SIMD directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-future]
!$omp distribute simd if(.true.)
do i = 1, 10
end do
@@ -85,7 +85,7 @@ program main
! ----------------------------------------------------------------------------
! DO SIMD
! ----------------------------------------------------------------------------
- !ERROR: IF clause is not allowed on DO SIMD directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-kartoffel]
+ !ERROR: IF clause is not allowed on DO SIMD directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-future]
!$omp do simd if(.true.)
do i = 1, 10
end do
@@ -542,7 +542,7 @@ program main
! ----------------------------------------------------------------------------
! TEAMS
! ----------------------------------------------------------------------------
- !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v4.5, try -fopenmp-version=52 [-Wopenmp-kartoffel]
+ !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v4.5, try -fopenmp-version=52 [-Wopenmp-future]
!$omp teams if(.true.)
!$omp end teams
@@ -629,7 +629,7 @@ program main
! ----------------------------------------------------------------------------
! TEAMS DISTRIBUTE SIMD
! ----------------------------------------------------------------------------
- !ERROR: IF clause is not allowed on TEAMS DISTRIBUTE SIMD directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-kartoffel]
+ !ERROR: IF clause is not allowed on TEAMS DISTRIBUTE SIMD directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-future]
!$omp teams distribute simd if(.true.)
do i = 1, 10
end do
diff --git a/flang/test/Semantics/OpenMP/if-clause-50-suggestion.f90 b/flang/test/Semantics/OpenMP/if-clause-50-suggestion.f90
index b13d76fbb490c..06a0f4c229745 100644
--- a/flang/test/Semantics/OpenMP/if-clause-50-suggestion.f90
+++ b/flang/test/Semantics/OpenMP/if-clause-50-suggestion.f90
@@ -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 [-Wopenmp-kartoffel]
+ !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v5.0, try -fopenmp-version=52 [-Wopenmp-future]
!$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 1b4505928a927..d56736b9a8059 100644
--- a/flang/test/Semantics/OpenMP/if-clause-50.f90
+++ b/flang/test/Semantics/OpenMP/if-clause-50.f90
@@ -530,7 +530,7 @@ program main
! ----------------------------------------------------------------------------
! TEAMS
! ----------------------------------------------------------------------------
- !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v5.0, try -fopenmp-version=52 [-Wopenmp-kartoffel]
+ !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v5.0, try -fopenmp-version=52 [-Wopenmp-future]
!$omp teams if(.true.)
!$omp end teams
diff --git a/flang/test/Semantics/OpenMP/requires04.f90 b/flang/test/Semantics/OpenMP/requires04.f90
index 8bf75d072270b..02f58eca5de73 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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!$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 de1c72f201a1e..ee49cd558d339 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-kartoffel]
+ !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-deprecated]
!$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 552e0cf405d2a..ac1fe38b092ba 100644
--- a/flang/test/Semantics/OpenMP/threadset-clause.f90
+++ b/flang/test/Semantics/OpenMP/threadset-clause.f90
@@ -3,12 +3,12 @@
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 [-Wopenmp-kartoffel]
+!ERROR: THREADSET clause is not allowed on TASK directive in OpenMP v4.5, try -fopenmp-version=60 [-Wopenmp-future]
!$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 [-Wopenmp-kartoffel]
+!ERROR: THREADSET clause is not allowed on TASKLOOP directive in OpenMP v4.5, try -fopenmp-version=60 [-Wopenmp-future]
!$omp taskloop threadset(omp_team)
do i = 1, 10
end do
>From 55cf344a5bc2e3e3758c44551ea06eb1a65333af Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Thu, 1 Oct 2026 08:19:18 -0500
Subject: [PATCH 5/6] Set overrides unconditionally, emit diagnostics
regardless of overrides
---
flang/lib/Semantics/check-omp-structure.cpp | 18 ++++++++---------
.../semantic-override-clause-werror.f90 | 20 +++++++++++++++++++
flang/test/Semantics/OpenMP/if-clause-45.f90 | 20 +++++++++++++++++++
flang/test/Semantics/OpenMP/if-clause-50.f90 | 4 ++++
4 files changed, 53 insertions(+), 9 deletions(-)
create mode 100644 flang/test/Integration/OpenMP/semantic-override-clause-werror.f90
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index 6a81b9e9b5266..b94d5f2fed0ba 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -540,7 +540,7 @@ static llvm::omp::Version AllowedInFutureVersion(llvm::omp::Clause clauseId,
if (v <= version) {
continue;
}
- if (IsClauseAllowedOnDirective(clauseId, dirId, v, semaCtx)) {
+ if (llvm::omp::isAllowedClauseForDirective(dirId, clauseId, v)) {
return v;
}
}
@@ -561,16 +561,18 @@ bool OmpStructureChecker::CheckAllowedClause(llvm::omp::Clause clauseId,
llvm::omp::Version version{context_.langOptions().getOpenMPVersion()};
- if (!IsClauseAllowedOnDirective(clauseId, dirId, version, &context_)) {
+ // Don't consult the overrides here. Checking the overrides would suppress
+ // repeated warnings for multiple occurrences of the same scenario (which
+ // may be desirable), but it would also suppress repeated errors with
+ // -Werror (which is undesirable).
+ if (!llvm::omp::isAllowedClauseForDirective(dirId, clauseId, version)) {
if (auto allowedInVersion{
AllowedInFutureVersion(clauseId, dirId, version, &context_)}) {
context_.Warn(common::UsageWarning::OpenMPFuture, 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);
- }
+ SetAllowedClauseOverride(clauseId, dirId);
} else {
context_.Say(clauseSource,
"%s clause is not allowed on %s directive"_err_en_US,
@@ -2843,10 +2845,8 @@ void OmpStructureChecker::Leave(const parser::OmpDeclareTargetDirective &x) {
if (toClause && version >= 52) {
context_.Warn(common::UsageWarning::OpenMPDeprecated, 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);
- }
+ SetAllowedClauseOverride(llvm::omp::Clause::OMPC_to,
+ llvm::omp::Directive::OMPD_declare_target);
}
}
diff --git a/flang/test/Integration/OpenMP/semantic-override-clause-werror.f90 b/flang/test/Integration/OpenMP/semantic-override-clause-werror.f90
new file mode 100644
index 0000000000000..01e7735244054
--- /dev/null
+++ b/flang/test/Integration/OpenMP/semantic-override-clause-werror.f90
@@ -0,0 +1,20 @@
+!RUN: %flang_fc1 -emit-hlfir %openmp_flags -fopenmp-version=45 -Wno-openmp-future -Werror -o - %s | FileCheck %s
+
+! IF clause is not allowed on SIMD in OpenMP 4.5, but is allowed in a later
+! version. We emit a warning for that, and after the semantic checks the
+! clause should be treated as allowed. Make sure that this is still the case
+! when the diagnostic is suppressed and -Werror is present.
+
+! This code should compile successfully.
+
+! CHECK: omp.simd if(%true)
+
+subroutine leaf(a, n)
+ integer :: n, i
+ real :: a(n)
+ !$omp simd if(.true.)
+ do i = 1, n
+ a(i) = a(i) + 1.0
+ end do
+ !$omp end simd
+end subroutine
diff --git a/flang/test/Semantics/OpenMP/if-clause-45.f90 b/flang/test/Semantics/OpenMP/if-clause-45.f90
index 15b1f850a17d8..1ed2fcf8c0ae1 100644
--- a/flang/test/Semantics/OpenMP/if-clause-45.f90
+++ b/flang/test/Semantics/OpenMP/if-clause-45.f90
@@ -63,18 +63,22 @@ program main
end do
!$omp end distribute simd
+ !ERROR: IF clause is not allowed on DISTRIBUTE SIMD directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-future]
!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 [-Wopenmp-future]
!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 [-Wopenmp-future]
+ !ERROR: IF clause is not allowed on DISTRIBUTE SIMD directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-future]
!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
@@ -91,18 +95,22 @@ program main
end do
!$omp end do simd
+ !ERROR: IF clause is not allowed on DO SIMD directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-future]
!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 [-Wopenmp-future]
!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 [-Wopenmp-future]
+ !ERROR: IF clause is not allowed on DO SIMD directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-future]
!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
@@ -208,23 +216,28 @@ program main
! ----------------------------------------------------------------------------
! SIMD
! ----------------------------------------------------------------------------
+ !ERROR: IF clause is not allowed on SIMD directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-future]
!$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 [-Wopenmp-future]
!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 [-Wopenmp-future]
!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 [-Wopenmp-future]
+ !ERROR: IF clause is not allowed on SIMD directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-future]
!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
@@ -546,14 +559,18 @@ program main
!$omp teams if(.true.)
!$omp end teams
+ !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v4.5, try -fopenmp-version=52 [-Wopenmp-future]
!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 [-Wopenmp-future]
!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 [-Wopenmp-future]
+ !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v4.5, try -fopenmp-version=52 [-Wopenmp-future]
!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
@@ -635,6 +652,8 @@ program main
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 [-Wopenmp-future]
+ !ERROR: IF clause is not allowed on TEAMS DISTRIBUTE SIMD directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-future]
!ERROR: TEAMS is not allowed as 'directive-name-modifier' in OpenMP v4.5, try -fopenmp-version=52
!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.)
@@ -642,6 +661,7 @@ program main
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 [-Wopenmp-future]
!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.f90 b/flang/test/Semantics/OpenMP/if-clause-50.f90
index d56736b9a8059..651b62d6a4344 100644
--- a/flang/test/Semantics/OpenMP/if-clause-50.f90
+++ b/flang/test/Semantics/OpenMP/if-clause-50.f90
@@ -534,14 +534,18 @@ program main
!$omp teams if(.true.)
!$omp end teams
+ !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v5.0, try -fopenmp-version=52 [-Wopenmp-future]
!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 [-Wopenmp-future]
!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 [-Wopenmp-future]
+ !ERROR: IF clause is not allowed on TEAMS directive in OpenMP v5.0, try -fopenmp-version=52 [-Wopenmp-future]
!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
>From 21958fc8e34d3827336f28a4da412ffcf341509d Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Thu, 1 Oct 2026 08:34:44 -0500
Subject: [PATCH 6/6] Forgot to add -Wno-experimental-option
---
.../test/Integration/OpenMP/semantic-override-clause-werror.f90 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/flang/test/Integration/OpenMP/semantic-override-clause-werror.f90 b/flang/test/Integration/OpenMP/semantic-override-clause-werror.f90
index 01e7735244054..7aded5c2a8209 100644
--- a/flang/test/Integration/OpenMP/semantic-override-clause-werror.f90
+++ b/flang/test/Integration/OpenMP/semantic-override-clause-werror.f90
@@ -1,4 +1,4 @@
-!RUN: %flang_fc1 -emit-hlfir %openmp_flags -fopenmp-version=45 -Wno-openmp-future -Werror -o - %s | FileCheck %s
+!RUN: %flang_fc1 -emit-hlfir %openmp_flags -fopenmp-version=45 -Wno-openmp-future -Werror -Wno-experimental-option -o - %s | FileCheck %s
! IF clause is not allowed on SIMD in OpenMP 4.5, but is allowed in a later
! version. We emit a warning for that, and after the semantic checks the
More information about the flang-commits
mailing list