[flang-commits] [flang] 1f1a5b3 - [flang][OpenMP] Remember decision of allowing past/future clause (#227419)

via flang-commits flang-commits at lists.llvm.org
Sat Oct 3 06:17:58 PDT 2026


Author: Krzysztof Parzyszek
Date: 2026-10-03T08:17:51-05:00
New Revision: 1f1a5b38374af3fc5afb52d91c91c0203b5edcdf

URL: https://github.com/llvm/llvm-project/commit/1f1a5b38374af3fc5afb52d91c91c0203b5edcdf
DIFF: https://github.com/llvm/llvm-project/commit/1f1a5b38374af3fc5afb52d91c91c0203b5edcdf.diff

LOG: [flang][OpenMP] Remember decision of allowing past/future clause (#227419)

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 OpenMPDeprecated and OpenMPFuture warning categories
to guard these warnings (and the corresponding `-Wopenmp-deprecated`
and `-Wopenmp-future` options).

Added: 
    flang/test/Integration/OpenMP/semantic-override-clause-compound.f90
    flang/test/Integration/OpenMP/semantic-override-clause-werror.f90
    flang/test/Lower/OpenMP/compound-version-override.f90

Modified: 
    flang/include/flang/Semantics/openmp-utils.h
    flang/include/flang/Semantics/semantics.h
    flang/include/flang/Support/Fortran-features.h
    flang/lib/Lower/OpenMP/Decomposer.cpp
    flang/lib/Semantics/check-omp-loop.cpp
    flang/lib/Semantics/check-omp-structure.cpp
    flang/lib/Semantics/check-omp-structure.h
    flang/lib/Semantics/check-omp-variant.cpp
    flang/lib/Semantics/openmp-utils.cpp
    flang/lib/Semantics/semantics.cpp
    flang/lib/Support/Fortran-features.cpp
    flang/test/Integration/OpenMP/scope-allocate-clause.f90
    flang/test/Semantics/OpenMP/affinity-clause.f90
    flang/test/Semantics/OpenMP/allocate-clause-version.f90
    flang/test/Semantics/OpenMP/allocate_do1.f90
    flang/test/Semantics/OpenMP/atomic.f90
    flang/test/Semantics/OpenMP/clause-validity02.f90
    flang/test/Semantics/OpenMP/declarative-directive01.f90
    flang/test/Semantics/OpenMP/declare-target01.f90
    flang/test/Semantics/OpenMP/declare-target02.f90
    flang/test/Semantics/OpenMP/declare-target06.f90
    flang/test/Semantics/OpenMP/if-clause-45-suggestion.f90
    flang/test/Semantics/OpenMP/if-clause-45.f90
    flang/test/Semantics/OpenMP/if-clause-50-suggestion.f90
    flang/test/Semantics/OpenMP/if-clause-50.f90
    flang/test/Semantics/OpenMP/requires04.f90
    flang/test/Semantics/OpenMP/requires05.f90
    flang/test/Semantics/OpenMP/threadset-clause.f90

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Semantics/openmp-utils.h b/flang/include/flang/Semantics/openmp-utils.h
index 769140a3147edf..c31459f256f622 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 dd81b1d8cf8541..d1365c4e7f46b6 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 06372bfc2cc1ea..021d157ae1f8d0 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,
+    OpenMPDeprecated, OpenMPFuture)
 
 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 d55534d94bb4ad..de61126eba80aa 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 7797c19db0f187..5165ca5f70d078 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 bef046d79df6cd..c163005593df5c 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -533,8 +533,22 @@ 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_);
+}
+
+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 (llvm::omp::isAllowedClauseForDirective(dirId, clauseId, v)) {
+      return v;
+    }
+  }
+  return llvm::omp::Version();
 }
 
 bool OmpStructureChecker::CheckAllowedClause(llvm::omp::Clause clauseId,
@@ -551,26 +565,18 @@ bool OmpStructureChecker::CheckAllowedClause(llvm::omp::Clause clauseId,
 
   llvm::omp::Version version{context_.langOptions().getOpenMPVersion()};
 
+  // 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)) {
-    llvm::omp::Version allowedInVersion{[&] {
-      for (llvm::omp::Version v : llvm::omp::getOpenMPVersions()) {
-        if (v <= version) {
-          continue;
-        }
-        if (llvm::omp::isAllowedClauseForDirective(dirId, clauseId, v)) {
-          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,
+    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));
+      SetAllowedClauseOverride(clauseId, dirId, allowedInVersion);
     } else {
       context_.Say(clauseSource,
           "%s clause is not allowed on %s directive"_err_en_US,
@@ -582,6 +588,30 @@ bool OmpStructureChecker::CheckAllowedClause(llvm::omp::Clause clauseId,
   return true;
 }
 
+// Mark clauseId as allowed on dirId. If dirId is a compound directive,
+// identify all leafs that allow the clause in version "since" or later,
+// and mark the clause as allowed on these leafs as well.
+// If dirId is not a compound directive, the "since" argument is ignored.
+void OmpStructureChecker::SetAllowedClauseOverride(llvm::omp::Clause clauseId,
+    llvm::omp::Directive dirId, llvm::omp::Version since) {
+  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()};
+    assert(since > version && "\"since\" should be a future version");
+    for (llvm::omp::Directive leaf : leafs) {
+      if (auto allowedInVersion{
+              AllowedInFutureVersion(clauseId, leaf, version, &context_)}) {
+        if (allowedInVersion <= since) {
+          overrides.allowedClauses[clauseId].set(leaf);
+        }
+      }
+    }
+  }
+}
+
 void OmpStructureChecker::AnalyzeObject(const parser::OmpObject &object) {
   if (GetCommonBlockFromObj(object) ||
       std::holds_alternative<parser::OmpObject::Invalid>(object.u)) {
@@ -1213,7 +1243,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);
     }
   }
@@ -2823,8 +2854,10 @@ 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::OpenMPDeprecated, toClause->source,
           "The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead."_warn_en_US);
+      SetAllowedClauseOverride(llvm::omp::Clause::OMPC_to,
+          llvm::omp::Directive::OMPD_declare_target, /*ignored*/ version);
     }
   }
 
@@ -3239,8 +3272,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) {
@@ -5569,15 +5602,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.
@@ -5596,8 +5630,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(
@@ -5673,7 +5707,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 c04336694f4232..79434e43c8db48 100644
--- a/flang/lib/Semantics/check-omp-structure.h
+++ b/flang/lib/Semantics/check-omp-structure.h
@@ -377,6 +377,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, llvm::omp::Version since);
   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 ac745accf95a35..7add875c96d883 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 a341cf4fa17065..794a748592bced 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 761ade6c1e97d4..224f5bcb1c18ab 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"
@@ -1005,4 +1006,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 4ae05994d98a75..9cd99008835ed1 100644
--- a/flang/lib/Support/Fortran-features.cpp
+++ b/flang/lib/Support/Fortran-features.cpp
@@ -197,6 +197,8 @@ 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::DataLength);
   warnUsage_.set(UsageWarning::IgnoredDirective);

diff  --git a/flang/test/Integration/OpenMP/scope-allocate-clause.f90 b/flang/test/Integration/OpenMP/scope-allocate-clause.f90
index 50bd1ab288d8d4..472b4c4f2b3b40 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/Integration/OpenMP/semantic-override-clause-compound.f90 b/flang/test/Integration/OpenMP/semantic-override-clause-compound.f90
new file mode 100644
index 00000000000000..79cb9a47762793
--- /dev/null
+++ b/flang/test/Integration/OpenMP/semantic-override-clause-compound.f90
@@ -0,0 +1,22 @@
+!RUN: %flang_fc1 -emit-hlfir %openmp_flags -fopenmp-version=45 -o - %s 2>&1 | FileCheck %s
+
+! Check that if we recommend using version 5.0 then we don't mark the IF
+! clause as allowed on leafs that only allow it on versions later than 5.0.
+! In this case SIMD allows IF in 5.0+, but TEAMS only allows it in 5.2.
+
+! CHECK: warning: IF clause is not allowed on TEAMS DISTRIBUTE SIMD directive in OpenMP v4.5, try -fopenmp-version=50
+! CHECK: omp.teams {
+! CHECK: omp.simd if(%false)
+
+subroutine tds(a, n)
+  integer :: n, i
+  real :: a(n)
+  !$omp target map(tofrom: a)
+  !$omp teams distribute simd if(.false.)
+  do i = 1, n
+    a(i) = a(i) + 1.0
+  end do
+  !$omp end teams distribute simd
+  !$omp end target
+end subroutine
+

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 00000000000000..7aded5c2a82099
--- /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 -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
+! 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/Lower/OpenMP/compound-version-override.f90 b/flang/test/Lower/OpenMP/compound-version-override.f90
new file mode 100644
index 00000000000000..112ab98e4cd274
--- /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/affinity-clause.f90 b/flang/test/Semantics/OpenMP/affinity-clause.f90
index 1b27ff242a9c0e..32e1ac432c7cd4 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-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 42db4e500b37d2..7081d774e9aceb 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-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
+  !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
+  !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
+  !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 1be215fb426982..6f5e4355af86c6 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-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
+    !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 25011513136acc..773c866e8c731c 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-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
-  !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-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
-  !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-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
+  !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 aa76c6d908b413..1906df9d0eb477 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-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 136b855ba7b42d..9e0612b5c8b53b 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-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-usage]
+    !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 03ee8da6f29926..b498cf649126da 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-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-usage]
+  !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-usage]
+  !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-usage]
+  !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-usage]
+  !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-usage]
+  !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-usage]
+  !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-usage]
+  !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-usage]
+  !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-usage]
+  !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-usage]
+  !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-usage]
+  !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-usage]
+  !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 aea6220ca4fb26..db9e51a197b2c0 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-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-usage]
+  !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-usage]
+  !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-usage]
+  !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-usage]
+  !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-usage]
+    !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-usage]
+    !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-usage]
+    !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-usage]
+    !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-usage]
+  !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-usage]
+  !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-usage]
+  !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-usage]
+  !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-usage]
+  !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-usage]
+  !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 5ad2377d3fcfd1..5dc4b8042ce1dd 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-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 5f21eea1adae68..d4c46e478a84ca 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-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
+  !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 181792a9ec20f6..1ed2fcf8c0ae1a 100644
--- a/flang/test/Semantics/OpenMP/if-clause-45.f90
+++ b/flang/test/Semantics/OpenMP/if-clause-45.f90
@@ -57,28 +57,28 @@ 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-future]
   !$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: 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
+  !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
-  !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-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
@@ -89,28 +89,28 @@ 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-future]
   !$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: 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
+  !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
-  !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-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
@@ -216,28 +216,28 @@ 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-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
+  !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
+  !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
-  !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-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
@@ -555,22 +555,22 @@ 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-future]
   !$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: 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
+  !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
-  !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-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
@@ -646,22 +646,22 @@ 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-future]
   !$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: 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: 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: 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-suggestion.f90 b/flang/test/Semantics/OpenMP/if-clause-50-suggestion.f90
index 5ac5cb588cf409..06a0f4c229745a 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-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 1f9b92df050b94..651b62d6a43448 100644
--- a/flang/test/Semantics/OpenMP/if-clause-50.f90
+++ b/flang/test/Semantics/OpenMP/if-clause-50.f90
@@ -530,22 +530,22 @@ 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-future]
   !$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: 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
+  !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
-  !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-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

diff  --git a/flang/test/Semantics/OpenMP/requires04.f90 b/flang/test/Semantics/OpenMP/requires04.f90
index ca8cf586dfbcc0..e392564c523d53 100644
--- a/flang/test/Semantics/OpenMP/requires04.f90
+++ b/flang/test/Semantics/OpenMP/requires04.f90
@@ -7,7 +7,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-deprecated]
   !$omp declare target to(x) device_type(nohost)
   !$omp declare target enter(x) device_type(nohost)
   !ERROR: REQUIRES directive with 'DYNAMIC_ALLOCATORS' clause found lexically after device construct

diff  --git a/flang/test/Semantics/OpenMP/requires05.f90 b/flang/test/Semantics/OpenMP/requires05.f90
index 07243b5d28e341..31f0b29edddda3 100644
--- a/flang/test/Semantics/OpenMP/requires05.f90
+++ b/flang/test/Semantics/OpenMP/requires05.f90
@@ -6,7 +6,7 @@
 ! 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-deprecated]
   !$omp declare target to(f)
   !$omp declare target enter(f)
   !ERROR: REQUIRES directive with 'DYNAMIC_ALLOCATORS' clause found lexically after device construct

diff  --git a/flang/test/Semantics/OpenMP/threadset-clause.f90 b/flang/test/Semantics/OpenMP/threadset-clause.f90
index 65a7ed74037cc8..ac1fe38b092ba6 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-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
+!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


        


More information about the flang-commits mailing list