[flang-commits] [flang] [flang][CLI] Have the CLI hint the flag to disable a warning (PR #144767)

Andre Kuhlenschmidt via flang-commits flang-commits at lists.llvm.org
Wed Jun 18 10:55:05 PDT 2025


https://github.com/akuhlens created https://github.com/llvm/llvm-project/pull/144767

Adds a hint to the warning message to disable a warning and updates the tests to expect this.

>From d8d3dd00da90328e21175ed274181e876aab51cc Mon Sep 17 00:00:00 2001
From: Andre Kuhlenschmidt <akuhlenschmi at nvidia.com>
Date: Wed, 18 Jun 2025 10:49:50 -0700
Subject: [PATCH] initial commit

---
 flang/include/flang/Parser/message.h          |   6 +-
 .../include/flang/Support/Fortran-features.h  |   4 +-
 flang/lib/Frontend/FrontendAction.cpp         |  10 ++-
 flang/lib/Parser/message.cpp                  |  30 ++++++-
 flang/lib/Semantics/semantics.cpp             |   4 +-
 flang/lib/Support/Fortran-features.cpp        |  29 +++----
 flang/test/Evaluate/fold-dim.f90              |   2 +-
 flang/test/Evaluate/fold-nearest.f90          |  22 ++---
 flang/test/Evaluate/fold-unsigned.f90         |   2 +-
 flang/test/Evaluate/folding03.f90             |  76 +++++++++---------
 flang/test/Evaluate/folding04.f90             |  22 ++---
 flang/test/Evaluate/folding05.f90             | Bin 10993 -> 11239 bytes
 flang/test/Evaluate/folding06.f90             |   4 +-
 flang/test/Evaluate/folding14.f90             |   4 +-
 flang/test/Evaluate/folding28.f90             |   2 +-
 flang/test/Semantics/OpenACC/acc-branch.f90   |   2 +-
 flang/test/Semantics/OpenACC/acc-data.f90     |   2 +-
 .../OpenACC/acc-declare-validity.f90          |   2 +-
 flang/test/Semantics/OpenACC/acc-serial.f90   |   6 +-
 .../Semantics/OpenMP/allocate-align01.f90     |   2 +-
 flang/test/Semantics/OpenMP/allocate01.f90    |   2 +-
 flang/test/Semantics/OpenMP/allocate02.f90    |   4 +-
 flang/test/Semantics/OpenMP/allocate03.f90    |   2 +-
 flang/test/Semantics/OpenMP/allocate05.f90    |   4 +-
 flang/test/Semantics/OpenMP/allocate06.f90    |   2 +-
 flang/test/Semantics/OpenMP/allocate09.f90    |  10 +--
 .../Semantics/OpenMP/clause-validity01.f90    |   4 +-
 flang/test/Semantics/OpenMP/copying.f90       |   8 +-
 .../OpenMP/declarative-directive01.f90        |   8 +-
 .../Semantics/OpenMP/declare-target01.f90     |  26 +++---
 .../Semantics/OpenMP/declare-target02.f90     |  30 +++----
 .../Semantics/OpenMP/declare-target03.f90     |   2 +-
 .../Semantics/OpenMP/declare-target06.f90     |   2 +-
 flang/test/Semantics/OpenMP/deprecation.f90   |  12 +--
 flang/test/Semantics/OpenMP/flush02.f90       |   2 +-
 .../test/Semantics/OpenMP/nested-barrier.f90  |   4 +-
 flang/test/Semantics/OpenMP/nested-master.f90 |  24 +++---
 flang/test/Semantics/OpenMP/nested-target.f90 |  14 ++--
 flang/test/Semantics/OpenMP/nested-teams.f90  |   2 +-
 flang/test/Semantics/OpenMP/ordered-simd.f90  |   8 +-
 .../Semantics/OpenMP/parallel-master-goto.f90 |   2 +-
 flang/test/Semantics/OpenMP/requires04.f90    |   2 +-
 flang/test/Semantics/OpenMP/requires05.f90    |   2 +-
 flang/test/Semantics/OpenMP/single03.f90      |   2 +-
 flang/test/Semantics/OpenMP/single04.f90      |  12 +--
 flang/test/Semantics/OpenMP/target01.f90      |   8 +-
 .../test/Semantics/OpenMP/threadprivate03.f90 |   2 +-
 .../test/Semantics/OpenMP/use_device_ptr1.f90 |   2 +-
 flang/test/Semantics/allocate09.f90           |   4 +-
 flang/test/Semantics/argshape01.f90           |   4 +-
 flang/test/Semantics/assign02.f90             |  14 ++--
 flang/test/Semantics/assign09.f90             |   4 +-
 flang/test/Semantics/associate01.f90          |   2 +-
 flang/test/Semantics/associated.f90           |  14 ++--
 flang/test/Semantics/bind-c02.f90             |   4 +-
 flang/test/Semantics/bind-c04.f90             |   2 +-
 flang/test/Semantics/bind-c06.f90             |   6 +-
 flang/test/Semantics/bind-c11.f90             |   2 +-
 flang/test/Semantics/bind-c13.f90             |   4 +-
 flang/test/Semantics/bind-c17.f90             |   2 +-
 flang/test/Semantics/bindings01.f90           |   6 +-
 flang/test/Semantics/bindings03.f90           |   4 +-
 flang/test/Semantics/block-data01.f90         |   2 +-
 .../test/Semantics/boz-literal-constants.f90  |   2 +-
 flang/test/Semantics/c7108.f90                |   4 +-
 flang/test/Semantics/c_f_pointer.f90          |   8 +-
 flang/test/Semantics/c_loc01.f90              |   6 +-
 flang/test/Semantics/call01.f90               |   6 +-
 flang/test/Semantics/call02.f90               |   6 +-
 flang/test/Semantics/call03.f90               |  12 +--
 flang/test/Semantics/call05.f90               |   4 +-
 flang/test/Semantics/call07.f90               |   6 +-
 flang/test/Semantics/call09.f90               |   2 +-
 flang/test/Semantics/call10.f90               |   2 +-
 flang/test/Semantics/call14.f90               |   4 +-
 flang/test/Semantics/call24.f90               |   2 +-
 flang/test/Semantics/call27.f90               |   4 +-
 flang/test/Semantics/call30.f90               |  30 +++----
 flang/test/Semantics/call31.f90               |   4 +-
 flang/test/Semantics/call33.f90               |   2 +-
 flang/test/Semantics/call34.f90               |   6 +-
 flang/test/Semantics/call35.f90               |   4 +-
 flang/test/Semantics/call36.f90               |   2 +-
 flang/test/Semantics/call37.f90               |  14 ++--
 flang/test/Semantics/call38.f90               |   4 +-
 flang/test/Semantics/call41.f90               |   2 +-
 flang/test/Semantics/call42.f90               |  12 +--
 flang/test/Semantics/call43.f90               |   6 +-
 flang/test/Semantics/call44.f90               |   4 +-
 flang/test/Semantics/case01.f90               |  12 +--
 flang/test/Semantics/common-blocks.f90        |   4 +-
 flang/test/Semantics/contiguous01.f90         |  16 ++--
 flang/test/Semantics/cuf01.cuf                |   8 +-
 flang/test/Semantics/cuf03.cuf                |  10 +--
 flang/test/Semantics/cuf04.cuf                |   4 +-
 flang/test/Semantics/cuf09.cuf                |   2 +-
 flang/test/Semantics/data06.f90               |   4 +-
 flang/test/Semantics/data17.f90               |   4 +-
 flang/test/Semantics/declarations04.f90       |   2 +-
 flang/test/Semantics/declarations05.f90       |   2 +-
 flang/test/Semantics/declarations07.f90       |   4 +-
 flang/test/Semantics/deferred01.f90           |   2 +-
 flang/test/Semantics/definable02.f90          |   4 +-
 flang/test/Semantics/dim01.f90                |  16 ++--
 flang/test/Semantics/dosemantics02.f90        |   4 +-
 flang/test/Semantics/dosemantics03.f90        |  36 ++++-----
 flang/test/Semantics/dosemantics12.f90        |   6 +-
 flang/test/Semantics/expr-errors05.f90        |  14 ++--
 flang/test/Semantics/expr-errors06.f90        |   2 +-
 flang/test/Semantics/final03.f90              |   2 +-
 flang/test/Semantics/forall01.f90             |  22 ++---
 flang/test/Semantics/forall02.f90             |   6 +-
 flang/test/Semantics/generic03.f90            |   2 +-
 flang/test/Semantics/generic06.f90            |   4 +-
 flang/test/Semantics/global01.f90             |   4 +-
 flang/test/Semantics/ichar01.f90              |   4 +-
 flang/test/Semantics/ignore_tkr01.f90         |  10 +--
 flang/test/Semantics/int-literals.f90         |   4 +-
 flang/test/Semantics/intrinsics02.f90         |   2 +-
 flang/test/Semantics/kinds05b.f90             |   4 +-
 flang/test/Semantics/label18.f90              |   4 +-
 flang/test/Semantics/local-vs-global.f90      |  32 ++++----
 flang/test/Semantics/long-name.f90            |   6 +-
 flang/test/Semantics/modfile43.f90            |   2 +-
 flang/test/Semantics/null-init.f90            |   2 +-
 flang/test/Semantics/null01.f90               |   6 +-
 flang/test/Semantics/pointer01.f90            |   2 +-
 flang/test/Semantics/procinterface02.f90      |   2 +-
 flang/test/Semantics/procinterface04.f90      |   4 +-
 flang/test/Semantics/resolve05.f90            |   8 +-
 flang/test/Semantics/resolve108.f90           |   4 +-
 flang/test/Semantics/resolve11.f90            |   4 +-
 flang/test/Semantics/resolve114.f90           |  20 ++---
 flang/test/Semantics/resolve118.f90           |   2 +-
 flang/test/Semantics/resolve17.f90            |   6 +-
 flang/test/Semantics/resolve18.f90            |   8 +-
 flang/test/Semantics/resolve20.f90            |   4 +-
 flang/test/Semantics/resolve24.f90            |   8 +-
 flang/test/Semantics/resolve30.f90            |   2 +-
 flang/test/Semantics/resolve31.f90            |   8 +-
 flang/test/Semantics/resolve35.f90            |  10 +--
 flang/test/Semantics/resolve37.f90            |  14 ++--
 flang/test/Semantics/resolve45.f90            |   6 +-
 flang/test/Semantics/resolve46.f90            |   4 +-
 flang/test/Semantics/resolve58.f90            |   8 +-
 flang/test/Semantics/resolve59.f90            |   6 +-
 flang/test/Semantics/resolve60.f90            |   2 +-
 flang/test/Semantics/resolve61.f90            |   2 +-
 flang/test/Semantics/resolve65.f90            |   4 +-
 flang/test/Semantics/resolve67.f90            |   4 +-
 flang/test/Semantics/resolve69.f90            |   6 +-
 flang/test/Semantics/resolve77.f90            |   4 +-
 flang/test/Semantics/resolve78.f90            |  10 +--
 flang/test/Semantics/resolve79.f90            |  10 +--
 flang/test/Semantics/resolve80.f90            |  12 +--
 flang/test/Semantics/resolve81.f90            |  38 ++++-----
 flang/test/Semantics/resolve82.f90            |  20 ++---
 flang/test/Semantics/resolve83.f90            |  12 +--
 flang/test/Semantics/resolve85.f90            |  10 +--
 flang/test/Semantics/resolve90.f90            |   2 +-
 flang/test/Semantics/resolve99.f90            |   4 +-
 flang/test/Semantics/separate-mp02.f90        |   2 +-
 flang/test/Semantics/spec-expr.f90            |   2 +-
 flang/test/Semantics/stmt-func01.f90          |  16 ++--
 flang/test/Semantics/stmt-func02.f90          |   6 +-
 flang/test/Semantics/structconst03.f90        |   2 +-
 flang/test/Semantics/structconst04.f90        |   2 +-
 flang/test/Semantics/structconst08.f90        |  10 +--
 flang/test/Semantics/structconst10.f90        |   8 +-
 flang/test/Semantics/transfer01.f90           |  10 +--
 flang/test/Semantics/undef-result01.f90       |   8 +-
 .../unittests/Common/FortranFeaturesTest.cpp  |   6 ++
 172 files changed, 658 insertions(+), 621 deletions(-)

diff --git a/flang/include/flang/Parser/message.h b/flang/include/flang/Parser/message.h
index e19b16c23b82b..912870e732450 100644
--- a/flang/include/flang/Parser/message.h
+++ b/flang/include/flang/Parser/message.h
@@ -292,7 +292,8 @@ class Message : public common::ReferenceCounted<Message> {
   std::optional<ProvenanceRange> GetProvenanceRange(
       const AllCookedSources &) const;
   void Emit(llvm::raw_ostream &, const AllCookedSources &,
-      bool echoSourceLine = true) const;
+      bool echoSourceLine = true, 
+      const common::LanguageFeatureControl *hintFlags = nullptr) const;
 
   // If this Message or any of its attachments locates itself via a CharBlock,
   // replace its location with the corresponding ProvenanceRange.
@@ -352,7 +353,8 @@ class Messages {
   void Copy(const Messages &);
   void ResolveProvenances(const AllCookedSources &);
   void Emit(llvm::raw_ostream &, const AllCookedSources &,
-      bool echoSourceLines = true) const;
+      bool echoSourceLines = true,
+      const common::LanguageFeatureControl *hintFlags = nullptr) const;
   void AttachTo(Message &, std::optional<Severity> = std::nullopt);
   bool AnyFatalError() const;
 
diff --git a/flang/include/flang/Support/Fortran-features.h b/flang/include/flang/Support/Fortran-features.h
index ea0845b7d605f..08a10cc301faf 100644
--- a/flang/include/flang/Support/Fortran-features.h
+++ b/flang/include/flang/Support/Fortran-features.h
@@ -149,9 +149,9 @@ class LanguageFeatureControl {
   // These two arrays map the enum values to their cannonical Cli spellings.
   // Since each of the CanonicalSpelling is a string in the domain of the map
   // above we just use a view of the string instead of another copy.
-  std::array<std::string_view, LanguageFeature_enumSize>
+  std::array<std::string, LanguageFeature_enumSize>
       languageFeatureCliCanonicalSpelling_;
-  std::array<std::string_view, UsageWarning_enumSize>
+  std::array<std::string, UsageWarning_enumSize>
       usageWarningCliCanonicalSpelling_;
   LanguageFeatures disable_;
   LanguageFeatures warnLanguage_;
diff --git a/flang/lib/Frontend/FrontendAction.cpp b/flang/lib/Frontend/FrontendAction.cpp
index d178fd6a9395d..1233deed17d03 100644
--- a/flang/lib/Frontend/FrontendAction.cpp
+++ b/flang/lib/Frontend/FrontendAction.cpp
@@ -171,7 +171,9 @@ bool FrontendAction::runParse(bool emitMessages) {
   if (emitMessages) {
     // Report any non-fatal diagnostics from getParsing now rather than
     // combining them with messages from semantics.
-    ci.getParsing().messages().Emit(llvm::errs(), ci.getAllCookedSources());
+    bool echoSourceLine{true};
+    auto &features {ci.getInvocation().getFortranOpts().features};
+    ci.getParsing().messages().Emit(llvm::errs(), ci.getAllCookedSources(), echoSourceLine, &features);
   }
   return true;
 }
@@ -223,6 +225,8 @@ bool FrontendAction::generateRtTypeTables() {
 
 template <unsigned N>
 bool FrontendAction::reportFatalErrors(const char (&message)[N]) {
+  bool echoSourceLine{true};
+  auto &features {instance->getInvocation().getFortranOpts().features};
   if (!instance->getParsing().messages().empty() &&
       (instance->getInvocation().getWarnAsErr() ||
        instance->getParsing().messages().AnyFatalError())) {
@@ -230,7 +234,7 @@ bool FrontendAction::reportFatalErrors(const char (&message)[N]) {
         clang::DiagnosticsEngine::Error, message);
     instance->getDiagnostics().Report(diagID) << getCurrentFileOrBufferName();
     instance->getParsing().messages().Emit(llvm::errs(),
-                                           instance->getAllCookedSources());
+                                           instance->getAllCookedSources(), echoSourceLine, &features);
     return true;
   }
   if (instance->getParsing().parseTree().has_value() &&
@@ -240,7 +244,7 @@ bool FrontendAction::reportFatalErrors(const char (&message)[N]) {
         clang::DiagnosticsEngine::Error, message);
     instance->getDiagnostics().Report(diagID) << getCurrentFileOrBufferName();
     instance->getParsing().messages().Emit(llvm::errs(),
-                                           instance->getAllCookedSources());
+                                           instance->getAllCookedSources(), echoSourceLine, &features);
     instance->getParsing().EmitMessage(
         llvm::errs(), instance->getParsing().finalRestingPlace(),
         "parser FAIL (final position)", "error: ", llvm::raw_ostream::RED);
diff --git a/flang/lib/Parser/message.cpp b/flang/lib/Parser/message.cpp
index 799998c54b531..610fb3f9e08a7 100644
--- a/flang/lib/Parser/message.cpp
+++ b/flang/lib/Parser/message.cpp
@@ -273,14 +273,36 @@ static llvm::raw_ostream::Colors PrefixColor(Severity severity) {
   return llvm::raw_ostream::SAVEDCOLOR;
 }
 
+static std::string hintLanguageControlFlag(
+  const common::LanguageFeatureControl *hintFlagPtr, 
+  std::optional<common::LanguageFeature> feature,
+  std::optional<common::UsageWarning> warning) {
+  if (hintFlagPtr) {
+    std::string_view flag{""};
+    if (warning) {
+      flag = hintFlagPtr->getDefaultCliSpelling(*warning);
+    } else if (feature) {
+      flag = hintFlagPtr->getDefaultCliSpelling(*feature);
+    }
+    if (!flag.empty()) {
+      std::string s{" [-Wno-" + std::string(flag) + "]"};
+      llvm::errs() << "hint: " << s << "\n";
+      return s;
+    }
+  }
+  return "";
+}
+
 static constexpr int MAX_CONTEXTS_EMITTED{2};
 static constexpr bool OMIT_SHARED_CONTEXTS{true};
 
 void Message::Emit(llvm::raw_ostream &o, const AllCookedSources &allCooked,
-    bool echoSourceLine) const {
+    bool echoSourceLine, const common::LanguageFeatureControl *hintFlagPtr) const {
   std::optional<ProvenanceRange> provenanceRange{GetProvenanceRange(allCooked)};
   const AllSources &sources{allCooked.allSources()};
-  sources.EmitMessage(o, provenanceRange, ToString(), Prefix(severity()),
+  std::string text{ToString()};
+  std::string hint{hintLanguageControlFlag(hintFlagPtr, languageFeature_, usageWarning_)};
+  sources.EmitMessage(o, provenanceRange, text + hint, Prefix(severity()),
       PrefixColor(severity()), echoSourceLine);
   // Refers to whether the attachment in the loop below is a context, but can't
   // be declared inside the loop because the previous iteration's
@@ -430,7 +452,7 @@ void Messages::ResolveProvenances(const AllCookedSources &allCooked) {
 }
 
 void Messages::Emit(llvm::raw_ostream &o, const AllCookedSources &allCooked,
-    bool echoSourceLines) const {
+    bool echoSourceLines, const common::LanguageFeatureControl *hintFlagPtr) const {
   std::vector<const Message *> sorted;
   for (const auto &msg : messages_) {
     sorted.push_back(&msg);
@@ -443,7 +465,7 @@ void Messages::Emit(llvm::raw_ostream &o, const AllCookedSources &allCooked,
       // Don't emit two identical messages for the same location
       continue;
     }
-    msg->Emit(o, allCooked, echoSourceLines);
+    msg->Emit(o, allCooked, echoSourceLines, hintFlagPtr);
     lastMsg = msg;
   }
 }
diff --git a/flang/lib/Semantics/semantics.cpp b/flang/lib/Semantics/semantics.cpp
index e07054f8ec564..c0160649e11e9 100644
--- a/flang/lib/Semantics/semantics.cpp
+++ b/flang/lib/Semantics/semantics.cpp
@@ -655,8 +655,10 @@ bool Semantics::Perform() {
 void Semantics::EmitMessages(llvm::raw_ostream &os) {
   // Resolve the CharBlock locations of the Messages to ProvenanceRanges
   // so messages from parsing and semantics are intermixed in source order.
+  bool echoSourceLine{true};
+  auto &features {context_.languageFeatures()};
   context_.messages().ResolveProvenances(context_.allCookedSources());
-  context_.messages().Emit(os, context_.allCookedSources());
+  context_.messages().Emit(os, context_.allCookedSources(), echoSourceLine, &features);
 }
 
 void SemanticsContext::DumpSymbols(llvm::raw_ostream &os) {
diff --git a/flang/lib/Support/Fortran-features.cpp b/flang/lib/Support/Fortran-features.cpp
index 08ded173de513..aeb0c0d3aa437 100644
--- a/flang/lib/Support/Fortran-features.cpp
+++ b/flang/lib/Support/Fortran-features.cpp
@@ -57,17 +57,15 @@ LanguageFeatureControl::LanguageFeatureControl() {
   ForEachLanguageFeature([&](auto feature) {
     std::string_view name{Fortran::common::EnumToString(feature)};
     std::string cliOption{details::CamelCaseToLowerCaseHyphenated(name)};
-    cliOptions_.insert({cliOption, {feature}});
-    languageFeatureCliCanonicalSpelling_[EnumToInt(feature)] =
-        std::string_view{cliOption};
+    cliOptions_.insert({std::string{cliOption}, {feature}});
+    languageFeatureCliCanonicalSpelling_[EnumToInt(feature)] = std::move(cliOption);
   });
 
   ForEachUsageWarning([&](auto warning) {
     std::string_view name{Fortran::common::EnumToString(warning)};
     std::string cliOption{details::CamelCaseToLowerCaseHyphenated(name)};
-    cliOptions_.insert({cliOption, {warning}});
-    usageWarningCliCanonicalSpelling_[EnumToInt(warning)] =
-        std::string_view{cliOption};
+    cliOptions_.insert({std::string{cliOption}, {warning}});
+    usageWarningCliCanonicalSpelling_[EnumToInt(warning)] = std::move(cliOption);
   });
 
   // These features must be explicitly enabled by command line options.
@@ -171,20 +169,23 @@ bool LanguageFeatureControl::ApplyCliOption(std::string input) {
   return false;
 }
 
+template <typename T, size_t ENUM_SIZE>
+static void replaceCliCanonicalSpelling(
+    std::unordered_map<std::string, std::variant<LanguageFeature, UsageWarning>> &cliOptions,
+    std::array<std::string, ENUM_SIZE> &canonicalSpelling, T t, std::string &input) {
+  cliOptions.erase({canonicalSpelling[EnumToInt(t)]});
+  canonicalSpelling[EnumToInt(t)] = std::string{input};
+  cliOptions.insert({std::string{input}, {t}});
+}
+
 void LanguageFeatureControl::ReplaceCliCanonicalSpelling(
     LanguageFeature f, std::string input) {
-  std::string_view &old{languageFeatureCliCanonicalSpelling_[EnumToInt(f)]};
-  cliOptions_.erase(std::string{old});
-  languageFeatureCliCanonicalSpelling_[EnumToInt(f)] = input;
-  cliOptions_.insert({input, {f}});
+  replaceCliCanonicalSpelling(cliOptions_, languageFeatureCliCanonicalSpelling_, f, input);
 }
 
 void LanguageFeatureControl::ReplaceCliCanonicalSpelling(
     UsageWarning w, std::string input) {
-  std::string_view &old{usageWarningCliCanonicalSpelling_[EnumToInt(w)]};
-  cliOptions_.erase(std::string{old});
-  usageWarningCliCanonicalSpelling_[EnumToInt(w)] = input;
-  cliOptions_.insert({input, {w}});
+  replaceCliCanonicalSpelling(cliOptions_, usageWarningCliCanonicalSpelling_, w, input);
 }
 
 std::vector<const char *> LanguageFeatureControl::GetNames(
diff --git a/flang/test/Evaluate/fold-dim.f90 b/flang/test/Evaluate/fold-dim.f90
index 40163c3f5a5ee..30dece869387a 100644
--- a/flang/test/Evaluate/fold-dim.f90
+++ b/flang/test/Evaluate/fold-dim.f90
@@ -11,7 +11,7 @@ module m
   logical, parameter :: test_a3 = dim(2., 1.) == 1.
   logical, parameter :: test_a4 = dim(2., -1.) == 3.
   logical, parameter :: test_a5 = dim(-1., 2.) == 0.
-  !WARN: warning: invalid argument on division
+  !WARN: warning: invalid argument on division [-Wno-folding-exception]
   real, parameter :: nan = 0./0.
   logical, parameter :: test_a6 = dim(nan, 1.) /= dim(nan, 1.)
 end module
diff --git a/flang/test/Evaluate/fold-nearest.f90 b/flang/test/Evaluate/fold-nearest.f90
index 48b9ef37840e3..9502740a7dc0f 100644
--- a/flang/test/Evaluate/fold-nearest.f90
+++ b/flang/test/Evaluate/fold-nearest.f90
@@ -19,16 +19,16 @@ module m1
   real, parameter :: negZero = sign(0., -1.)
   logical, parameter :: test_12 = nearest(negZero, 1.) == minSubnormal
   logical, parameter :: test_13 = nearest(negZero, -1.) == -minSubnormal
-  !WARN: warning: NEAREST: S argument is zero
+  !WARN: warning: NEAREST: S argument is zero [-Wno-folding-value-checks]
   logical, parameter :: test_14 = nearest(0., negZero) == -minSubnormal
-  !WARN: warning: NEAREST: S argument is zero
+  !WARN: warning: NEAREST: S argument is zero [-Wno-folding-value-checks]
   logical, parameter :: test_15 = nearest(negZero, 0.) == minSubnormal
   logical, parameter :: test_16 = nearest(tiny(1.),-1.) == 1.1754942E-38
   logical, parameter :: test_17 = nearest(tiny(1.),1.) == 1.1754945E-38
  contains
   subroutine subr(a)
     real, intent(in) :: a
-    !WARN: warning: NEAREST: S argument is zero
+    !WARN: warning: NEAREST: S argument is zero [-Wno-folding-value-checks]
     print *, nearest(a, 0.)
   end
 end module
@@ -42,7 +42,7 @@ module m2
   logical, parameter :: test_2 = ieee_next_after(minSubnormal, -1.) == 0
   logical, parameter :: test_3 = ieee_next_after(1., 2.) == 1.0000001
   logical, parameter :: test_4 = ieee_next_after(1.0000001, -1.) == 1
-  !WARN: warning: division by zero
+  !WARN: warning: division by zero [-Wno-folding-exception]
   real, parameter :: inf = 1. / 0.
   logical, parameter :: test_5 = ieee_next_after(inf, inf) == inf
   logical, parameter :: test_6 = ieee_next_after(inf, -inf) == h
@@ -54,12 +54,12 @@ module m2
   logical, parameter :: test_11 = ieee_next_after(1.9999999999999999999_10, 3.) == 2._10
 #endif
   logical, parameter :: test_12 = ieee_next_after(1., 1.) == 1.
-  !WARN: warning: invalid argument on division
+  !WARN: warning: invalid argument on division [-Wno-folding-exception]
   real, parameter :: nan = 0. / 0.
-  !WARN: warning: IEEE_NEXT_AFTER intrinsic folding: arguments are unordered
+  !WARN: warning: IEEE_NEXT_AFTER intrinsic folding: arguments are unordered [-Wno-folding-value-checks]
   real, parameter :: x13 = ieee_next_after(nan, nan)
   logical, parameter :: test_13 = .not. (x13 == x13)
-  !WARN: warning: IEEE_NEXT_AFTER intrinsic folding: arguments are unordered
+  !WARN: warning: IEEE_NEXT_AFTER intrinsic folding: arguments are unordered [-Wno-folding-value-checks]
   real, parameter :: x14 = ieee_next_after(nan, 0.)
   logical, parameter :: test_14 = .not. (x14 == x14)
 end module
@@ -72,7 +72,7 @@ module m3
   logical, parameter :: test_2 = ieee_next_down(0.d0) == -minSubnormal
   logical, parameter :: test_3 = ieee_next_up(1.d0) == 1.0000000000000002d0
   logical, parameter :: test_4 = ieee_next_down(1.0000000000000002d0) == 1.d0
-  !WARN: warning: division by zero
+  !WARN: warning: division by zero [-Wno-folding-exception]
   real(kind(0.d0)), parameter :: inf = 1.d0 / 0.d0
   logical, parameter :: test_5 = ieee_next_up(huge(0.d0)) == inf
   logical, parameter :: test_6 = ieee_next_down(-huge(0.d0)) == -inf
@@ -82,12 +82,12 @@ module m3
   logical, parameter :: test_10 = ieee_next_down(-inf) == -inf
   logical, parameter :: test_11 = ieee_next_up(1.9999999999999997d0) == 2.d0
   logical, parameter :: test_12 = ieee_next_down(2.d0) == 1.9999999999999997d0
-  !WARN: warning: invalid argument on division
+  !WARN: warning: invalid argument on division [-Wno-folding-exception]
   real(kind(0.d0)), parameter :: nan = 0.d0 / 0.d0
-  !WARN: warning: IEEE_NEXT_UP intrinsic folding: argument is NaN
+  !WARN: warning: IEEE_NEXT_UP intrinsic folding: argument is NaN [-Wno-folding-exception]
   real(kind(0.d0)), parameter :: x13 = ieee_next_up(nan)
   logical, parameter :: test_13 = .not. (x13 == x13)
-  !WARN: warning: IEEE_NEXT_DOWN intrinsic folding: argument is NaN
+  !WARN: warning: IEEE_NEXT_DOWN intrinsic folding: argument is NaN [-Wno-folding-exception]
   real(kind(0.d0)), parameter :: x14 = ieee_next_down(nan)
   logical, parameter :: test_14 = .not. (x14 == x14)
 end module
diff --git a/flang/test/Evaluate/fold-unsigned.f90 b/flang/test/Evaluate/fold-unsigned.f90
index 719bdcc1a40b9..27f2fe4404483 100644
--- a/flang/test/Evaluate/fold-unsigned.f90
+++ b/flang/test/Evaluate/fold-unsigned.f90
@@ -24,7 +24,7 @@ module m
 
   logical, parameter :: test_cus0    = int(0u,1) == 0
   logical, parameter :: test_cus0_k  = kind(int(0u,1)) == 1
-  !WARN: warning: conversion of 255_U1 to INTEGER(1) overflowed; result is -1
+  !WARN: warning: conversion of 255_U1 to INTEGER(1) overflowed; result is -1 [-Wno-folding-exception]
   logical, parameter :: test_cus255  = int(255u_1,1) == -1
   logical, parameter :: test_cur255  = real(255u) == 255.
 
diff --git a/flang/test/Evaluate/folding03.f90 b/flang/test/Evaluate/folding03.f90
index 827bde86757c8..6441cde946a4a 100644
--- a/flang/test/Evaluate/folding03.f90
+++ b/flang/test/Evaluate/folding03.f90
@@ -15,32 +15,32 @@ module integer_tests
   ! Integer division by zero are not tested here because they are handled as fatal
   ! errors in constants.
 
-  !WARN: warning: INTEGER(4) negation overflowed
+  !WARN: warning: INTEGER(4) negation overflowed [-Wno-folding-exception]
   logical, parameter :: test_overflow_unary_minus1 = (-i4_nmax).EQ.i4_nmax
   logical, parameter :: test_no_overflow_unary_minus1 = (-i4_pmax).EQ.(i4_nmax+1_4)
   logical, parameter :: test_no_overflow_unary_plus1 = (+i4_pmax).EQ.i4_pmax
   logical, parameter :: test_no_overflow_unary_plus2 = (+i4_nmax).EQ.i4_nmax
 
-  !WARN: warning: INTEGER(4) addition overflowed
+  !WARN: warning: INTEGER(4) addition overflowed [-Wno-folding-exception]
   logical, parameter :: test_overflow_add1 = (i4_pmax+1_4).EQ.i4_nmax
-  !WARN: warning: INTEGER(4) addition overflowed
+  !WARN: warning: INTEGER(4) addition overflowed [-Wno-folding-exception]
   logical, parameter :: test_overflow_add2 = (i4_nmax + (-1_4)).EQ.i4_pmax
-  !WARN: warning: INTEGER(4) addition overflowed
+  !WARN: warning: INTEGER(4) addition overflowed [-Wno-folding-exception]
   logical, parameter :: test_overflow_add3 = (i4_pmax + i4_pmax).EQ.(-2_4)
-  !WARN: warning: INTEGER(4) addition overflowed
+  !WARN: warning: INTEGER(4) addition overflowed [-Wno-folding-exception]
   logical, parameter :: test_overflow_add4 = (i4_nmax + i4_nmax).EQ.(0_4)
   logical, parameter :: test_no_overflow_add1 = (i4_pmax + 0_4).EQ.i4_pmax
   logical, parameter :: test_no_overflow_add2 = (i4_nmax + (-0_4)).EQ.i4_nmax
   logical, parameter :: test_no_overflow_add3 = (i4_pmax + i4_nmax).EQ.(-1_4)
   logical, parameter :: test_no_overflow_add4 = (i4_nmax + i4_pmax).EQ.(-1_4)
 
-  !WARN: warning: INTEGER(4) subtraction overflowed
+  !WARN: warning: INTEGER(4) subtraction overflowed [-Wno-folding-exception]
   logical, parameter :: test_overflow_sub1 = (i4_nmax - 1_4).EQ.i4_pmax
-  !WARN: warning: INTEGER(4) subtraction overflowed
+  !WARN: warning: INTEGER(4) subtraction overflowed [-Wno-folding-exception]
   logical, parameter :: test_overflow_sub2 = (i4_pmax - (-1_4)).EQ.i4_nmax
-  !WARN: warning: INTEGER(4) subtraction overflowed
+  !WARN: warning: INTEGER(4) subtraction overflowed [-Wno-folding-exception]
   logical, parameter :: test_overflow_sub3 = (i4_nmax - i4_pmax).EQ.(1_4)
-  !WARN: warning: INTEGER(4) subtraction overflowed
+  !WARN: warning: INTEGER(4) subtraction overflowed [-Wno-folding-exception]
   logical, parameter :: test_overflow_sub4 = (i4_pmax - i4_nmax).EQ.(-1_4)
   logical, parameter :: test_no_overflow_sub1 = (i4_nmax - 0_4).EQ.i4_nmax
   logical, parameter :: test_no_overflow_sub2 = (i4_pmax - (-0_4)).EQ.i4_pmax
@@ -48,23 +48,23 @@ module integer_tests
   logical, parameter :: test_no_overflow_sub4 = (i4_pmax - i4_pmax).EQ.0_4
 
 
-  !WARN: warning: INTEGER(4) multiplication overflowed
+  !WARN: warning: INTEGER(4) multiplication overflowed [-Wno-folding-exception]
   logical, parameter :: test_overflow_mult1 = (i4_pmax*2_4).EQ.(-2_4)
-  !WARN: warning: INTEGER(4) multiplication overflowed
+  !WARN: warning: INTEGER(4) multiplication overflowed [-Wno-folding-exception]
   logical, parameter :: test_overflow_mult2 = (i4_nmax*2_4).EQ.(0_4)
-  !WARN: warning: INTEGER(4) multiplication overflowed
+  !WARN: warning: INTEGER(4) multiplication overflowed [-Wno-folding-exception]
   logical, parameter :: test_overflow_mult3 = (i4_nmax*i4_nmax).EQ.(0_4)
-  !WARN: warning: INTEGER(4) multiplication overflowed
+  !WARN: warning: INTEGER(4) multiplication overflowed [-Wno-folding-exception]
   logical, parameter :: test_overflow_mult4 = (i4_pmax*i4_pmax).EQ.(1_4)
 
-  !WARN: warning: INTEGER(4) division overflowed
+  !WARN: warning: INTEGER(4) division overflowed [-Wno-folding-exception]
   logical, parameter :: test_overflow_div1 = (i4_nmax/(-1_4)).EQ.(i4_nmax)
   logical, parameter :: test_no_overflow_div1 = (i4_nmax/(-2_4)).EQ.(1_4 + i4_pmax/2_4)
   logical, parameter :: test_no_overflow_div2 = (i4_nmax/i4_nmax).EQ.(1_4)
 
-  !WARN: warning: INTEGER(4) power overflowed
+  !WARN: warning: INTEGER(4) power overflowed [-Wno-folding-exception]
   logical, parameter :: test_overflow_pow1 = (i4_pmax**2_4).EQ.(1_4)
-  !WARN: warning: INTEGER(4) power overflowed
+  !WARN: warning: INTEGER(4) power overflowed [-Wno-folding-exception]
   logical, parameter :: test_overflow_pow3 = (i4_nmax**2_4).EQ.(0_4)
   logical, parameter :: test_no_overflow_pow1 = ((-1_4)**i4_nmax).EQ.(1_4)
   logical, parameter :: test_no_overflow_pow2 = ((-1_4)**i4_pmax).EQ.(-1_4)
@@ -76,12 +76,12 @@ module real_tests
 
   real(4), parameter :: r4_pmax = 3.4028235E38
   real(4), parameter :: r4_nmax = -3.4028235E38
-  !WARN: warning: invalid argument on division
+  !WARN: warning: invalid argument on division [-Wno-folding-exception]
   real(4), parameter :: r4_nan = 0._4/0._4
   TEST_ISNAN(r4_nan)
-  !WARN: warning: division by zero
+  !WARN: warning: division by zero [-Wno-folding-exception]
   real(4), parameter :: r4_pinf = 1._4/0._4
-  !WARN: warning: division by zero
+  !WARN: warning: division by zero [-Wno-folding-exception]
   real(4), parameter :: r4_ninf = -1._4/0._4
 
   logical, parameter :: test_r4_nan_parentheses1 = .NOT.(((r4_nan)).EQ.r4_nan)
@@ -106,13 +106,13 @@ module real_tests
   real(4), parameter :: r4_nan_plus = (+r4_nan)
   TEST_ISNAN(r4_nan_plus)
 
-  !WARN: warning: overflow on addition
+  !WARN: warning: overflow on addition [-Wno-folding-exception]
   logical, parameter :: test_inf_r4_add9 = (r4_pmax + r4_pmax).eq.(r4_pinf)
-  !WARN: warning: overflow on addition
+  !WARN: warning: overflow on addition [-Wno-folding-exception]
   logical, parameter :: test_inf_r4_add10 = (r4_nmax + r4_nmax).eq.(r4_ninf)
-  !WARN: warning: overflow on subtraction
+  !WARN: warning: overflow on subtraction [-Wno-folding-exception]
   logical, parameter :: test_inf_r4_sub9 = (r4_pmax - r4_nmax).eq.(r4_pinf)
-  !WARN: warning: overflow on subtraction
+  !WARN: warning: overflow on subtraction [-Wno-folding-exception]
   logical, parameter :: test_inf_r4_sub10 = (r4_nmax - r4_pmax).eq.(r4_ninf)
 
   ! No warnings expected below (inf propagation).
@@ -125,16 +125,16 @@ module real_tests
   logical, parameter :: test_inf_r4_add7 = (r4_ninf + 0._4).EQ.(r4_ninf)
   logical, parameter :: test_inf_r4_add8 = (r4_pinf + 0._4).EQ.(r4_pinf)
 
-  !WARN: warning: invalid argument on subtraction
+  !WARN: warning: invalid argument on subtraction [-Wno-folding-exception]
   real(4), parameter :: r4_nan_sub1 = r4_pinf - r4_pinf
   TEST_ISNAN(r4_nan_sub1)
-  !WARN: warning: invalid argument on subtraction
+  !WARN: warning: invalid argument on subtraction [-Wno-folding-exception]
   real(4), parameter :: r4_nan_sub2 = r4_ninf - r4_ninf
   TEST_ISNAN(r4_nan_sub2)
-  !WARN: warning: invalid argument on addition
+  !WARN: warning: invalid argument on addition [-Wno-folding-exception]
   real(4), parameter :: r4_nan_add1 = r4_ninf + r4_pinf
   TEST_ISNAN(r4_nan_add1)
-  !WARN: warning: invalid argument on addition
+  !WARN: warning: invalid argument on addition [-Wno-folding-exception]
   real(4), parameter :: r4_nan_add2 = r4_pinf + r4_ninf
   TEST_ISNAN(r4_nan_add2)
 
@@ -156,13 +156,13 @@ module real_tests
   real(4), parameter :: r4_nan_add6 = r4_nan + r4_nan
   TEST_ISNAN(r4_nan_add6)
 
-  !WARN: warning: overflow on multiplication
+  !WARN: warning: overflow on multiplication [-Wno-folding-exception]
   logical, parameter :: test_inf_r4_mult1 = (1.5_4*r4_pmax).eq.(r4_pinf)
-  !WARN: warning: overflow on multiplication
+  !WARN: warning: overflow on multiplication [-Wno-folding-exception]
   logical, parameter :: test_inf_r4_mult2 = (1.5_4*r4_nmax).eq.(r4_ninf)
-  !WARN: warning: overflow on division
+  !WARN: warning: overflow on division [-Wno-folding-exception]
   logical, parameter :: test_inf_r4_div1 = (r4_nmax/(-0.5_4)).eq.(r4_pinf)
-  !WARN: warning: overflow on division
+  !WARN: warning: overflow on division [-Wno-folding-exception]
   logical, parameter :: test_inf_r4_div2 = (r4_pmax/(-0.5_4)).eq.(r4_ninf)
 
   ! No warnings expected below (inf propagation).
@@ -179,25 +179,25 @@ module real_tests
   logical, parameter :: test_inf_r4_div9 = (r4_nmax/r4_pinf).EQ.(0.)
   logical, parameter :: test_inf_r4_div10 = (r4_nmax/r4_ninf).EQ.(0.)
 
-  !WARN: warning: invalid argument on division
+  !WARN: warning: invalid argument on division [-Wno-folding-exception]
   real(4), parameter :: r4_nan_div1 = 0._4/0._4
   TEST_ISNAN(r4_nan_div1)
-  !WARN: warning: invalid argument on division
+  !WARN: warning: invalid argument on division [-Wno-folding-exception]
   real(4), parameter :: r4_nan_div2 = r4_ninf/r4_ninf
   TEST_ISNAN(r4_nan_div2)
-  !WARN: warning: invalid argument on division
+  !WARN: warning: invalid argument on division [-Wno-folding-exception]
   real(4), parameter :: r4_nan_div3 = r4_ninf/r4_pinf
   TEST_ISNAN(r4_nan_div3)
-  !WARN: warning: invalid argument on division
+  !WARN: warning: invalid argument on division [-Wno-folding-exception]
   real(4), parameter :: r4_nan_div4 = r4_pinf/r4_ninf
   TEST_ISNAN(r4_nan_div4)
-  !WARN: warning: invalid argument on division
+  !WARN: warning: invalid argument on division [-Wno-folding-exception]
   real(4), parameter :: r4_nan_div5 = r4_pinf/r4_pinf
   TEST_ISNAN(r4_nan_div5)
-  !WARN: warning: invalid argument on multiplication
+  !WARN: warning: invalid argument on multiplication [-Wno-folding-exception]
   real(4), parameter :: r4_nan_mult1 = r4_pinf*0._4
   TEST_ISNAN(r4_nan_mult1)
-  !WARN: warning: invalid argument on multiplication
+  !WARN: warning: invalid argument on multiplication [-Wno-folding-exception]
   real(4), parameter :: r4_nan_mult2 = 0._4*r4_ninf
   TEST_ISNAN(r4_nan_mult2)
 
diff --git a/flang/test/Evaluate/folding04.f90 b/flang/test/Evaluate/folding04.f90
index 08c5c6eee9b12..5ceab4dedec77 100644
--- a/flang/test/Evaluate/folding04.f90
+++ b/flang/test/Evaluate/folding04.f90
@@ -10,11 +10,11 @@ module real_tests
 
   real(4), parameter :: r4_pmax = 3.4028235E38
   real(4), parameter :: r4_nmax = -3.4028235E38
-  !WARN: warning: invalid argument on division
+  !WARN: warning: invalid argument on division [-Wno-folding-exception]
   real(4), parameter :: r4_nan = 0._4/0._4
-  !WARN: warning: division by zero
+  !WARN: warning: division by zero [-Wno-folding-exception]
   real(4), parameter :: r4_pinf = 1._4/0._4
-  !WARN: warning: division by zero
+  !WARN: warning: division by zero [-Wno-folding-exception]
   real(4), parameter :: r4_ninf = -1._4/0._4
 
   !WARN: warning: argument is out of range [-1., 1.]
@@ -37,7 +37,7 @@ module real_tests
   TEST_ISNAN(nan_r8_dasin1)
   !WARN: warning: complex argument must be different from zero
   complex(4), parameter :: c4_clog1 = clog((0., 0.))
-  !WARN: warning: MOD: P argument is zero
+  !WARN: warning: MOD: P argument is zero [-Wno-folding-avoids-runtime-crash]
   real(4), parameter :: nan_r4_mod = mod(3.5, 0.)
   TEST_ISNAN(nan_r4_mod)
   real(4), parameter :: ok_r4_gamma = gamma(-1.1)
@@ -53,17 +53,17 @@ module real_tests
   !WARN: warning: 'x' and 'y' arguments must not be both zero
   real(4), parameter :: r4_atan2 = atan2(0., 0.)
 
-  !WARN: warning: overflow on evaluation of intrinsic function or operation
+  !WARN: warning: overflow on evaluation of intrinsic function or operation [-Wno-folding-exception]
   logical, parameter :: test_exp_overflow = exp(256._4).EQ.r4_pinf
  contains
   subroutine s1(a,j)
-    !WARN: warning: MOD: P argument is zero
+    !WARN: warning: MOD: P argument is zero [-Wno-folding-avoids-runtime-crash]
     print *, mod(a, 0.)
-    !WARN: warning: MODULO: P argument is zero
+    !WARN: warning: MODULO: P argument is zero [-Wno-folding-avoids-runtime-crash]
     print *, modulo(a, 0.)
-    !WARN: warning: MOD: P argument is zero
+    !WARN: warning: MOD: P argument is zero [-Wno-folding-avoids-runtime-crash]
     print *, mod(j, 0.)
-    !WARN: warning: MODULO: P argument is zero
+    !WARN: warning: MODULO: P argument is zero [-Wno-folding-avoids-runtime-crash]
     print *, modulo(j, 0.)
   end
 end module
@@ -86,13 +86,13 @@ module specific_extremums
   ! specified for f18 (converting the result).
   integer(8), parameter :: max_i32_8 = 2_8**31-1
   integer, parameter :: expected_min0 = int(min(max_i32_8, 2_8*max_i32_8), 4)
-  !WARN: portability: Argument types do not match specific intrinsic 'min0' requirements; using 'min' generic instead and converting the result to INTEGER(4) if needed
+  !WARN: portability: Argument types do not match specific intrinsic 'min0' requirements; using 'min' generic instead and converting the result to INTEGER(4) if needed [-Wno-use-generic-intrinsic-when-specific-doesnt-match]
   integer, parameter :: result_min0 =  min0(max_i32_8, 2_8*max_i32_8)
   ! result_min0 would be -2  if arguments were converted to default integer.
   logical, parameter :: test_min0 = expected_min0 .EQ. result_min0
 
   real, parameter :: expected_amax0 = real(max(max_i32_8, 2_8*max_i32_8), 4)
-  !WARN: portability: Argument types do not match specific intrinsic 'amax0' requirements; using 'max' generic instead and converting the result to REAL(4) if needed
+  !WARN: portability: Argument types do not match specific intrinsic 'amax0' requirements; using 'max' generic instead and converting the result to REAL(4) if needed [-Wno-use-generic-intrinsic-when-specific-doesnt-match]
   real, parameter :: result_amax0 = amax0(max_i32_8, 2_8*max_i32_8)
   ! result_amax0 would be 2.1474836E+09 if arguments were converted to default integer first.
   logical, parameter :: test_amax0 = expected_amax0 .EQ. result_amax0
diff --git a/flang/test/Evaluate/folding05.f90 b/flang/test/Evaluate/folding05.f90
index eb762775e641679cac704694f6d4aa6fb191083f..5971432f09ce60437b689087a44c7c82ac8582c7 100644
GIT binary patch
delta 339
zcmewu`aFDt4wH;Rv~GA_zHVB6PD*B8x^7uwPHC!caz<)$c5&=vM_&2K=a|?h2QkGG
zRJi#Z({Dz?s$Q_fF-xLZnp%;ZT2PXipBFp%9hdavL=Fx7=4 at nF-n@oGoPcd0RnIs%
a81dTXgWsk=E|tk~+@}aC+U&!#R1N at Dg?PpQ

delta 92
zcmaDJ{xNie4%6gGeDaginNmRXW;W*Ej9`HP7WU1~tl`X)8M&k;pXJa53d(IZ;FJN$
f%1t)lWZm4&#lZ-cJ;rSW7Bu3y09IwgyIKwaizOW(

diff --git a/flang/test/Evaluate/folding06.f90 b/flang/test/Evaluate/folding06.f90
index da434fb6d4869..4d0a63f98b127 100644
--- a/flang/test/Evaluate/folding06.f90
+++ b/flang/test/Evaluate/folding06.f90
@@ -7,12 +7,12 @@ module m
   integer, pointer :: int_pointer
   integer, allocatable :: int_allocatable
   logical, parameter :: test_Assoc1 = .not.(associated(null()))
-  !WARN: portability: POINTER= argument of ASSOCIATED() is required by some other compilers to be a valid left-hand side of a pointer assignment statement
+  !WARN: portability: POINTER= argument of ASSOCIATED() is required by some other compilers to be a valid left-hand side of a pointer assignment statement [-Wno-portability]
   !WARN: because: 'NULL()' is a null pointer
   logical, parameter :: test_Assoc2 = .not.(associated(null(), null()))
   logical, parameter :: test_Assoc3 = .not.(associated(null(int_pointer)))
   logical, parameter :: test_Alloc1 = .not.(allocated(null(int_allocatable)))
-  !WARN: portability: POINTER= argument of ASSOCIATED() is required by some other compilers to be a valid left-hand side of a pointer assignment statement
+  !WARN: portability: POINTER= argument of ASSOCIATED() is required by some other compilers to be a valid left-hand side of a pointer assignment statement [-Wno-portability]
   !WARN: because: 'NULL()' is a null pointer
   logical, parameter :: test_Assoc5 = .not. associated(null(), null(int_pointer))
 
diff --git a/flang/test/Evaluate/folding14.f90 b/flang/test/Evaluate/folding14.f90
index 2cf1c32f6cb3f..6e8c8dd54017e 100644
--- a/flang/test/Evaluate/folding14.f90
+++ b/flang/test/Evaluate/folding14.f90
@@ -4,9 +4,9 @@ module m1
   logical, parameter :: results(*) = isnan([ &
     0., &
     -0., &
-!WARN: warning: division by zero
+!WARN: warning: division by zero [-Wno-folding-exception]
     1./0., &
-!WARN: warning: invalid argument on division
+!WARN: warning: invalid argument on division [-Wno-folding-exception]
     0./0., &
     real(z'7ff80001',kind=4), &
     real(z'fff80001',kind=4), &
diff --git a/flang/test/Evaluate/folding28.f90 b/flang/test/Evaluate/folding28.f90
index 642919de7414a..280b43fa6123a 100644
--- a/flang/test/Evaluate/folding28.f90
+++ b/flang/test/Evaluate/folding28.f90
@@ -15,7 +15,7 @@ module m
   ! -0 (sqrt is -0)
   real(8), parameter :: n08 = z'8000000000000000'
   real(8), parameter :: sqrt_n08 = sqrt(n08)
-  !WARN: warning: division by zero
+  !WARN: warning: division by zero [-Wno-folding-exception]
   real(8), parameter :: inf_n08 = 1.0_8 / sqrt_n08, inf_n08z = z'fff0000000000000'
   logical, parameter :: test_n08 = inf_n08 == inf_n08z
   ! min normal
diff --git a/flang/test/Semantics/OpenACC/acc-branch.f90 b/flang/test/Semantics/OpenACC/acc-branch.f90
index b3692d0165890..0e3385e43686e 100644
--- a/flang/test/Semantics/OpenACC/acc-branch.f90
+++ b/flang/test/Semantics/OpenACC/acc-branch.f90
@@ -74,7 +74,7 @@ subroutine openacc_clause_validity
   ! Exit branches out of parallel construct, attached to an OpenACC parallel construct.
   thisblk: BLOCK
     fortname: if (.true.) then
-      !PORTABILITY: The construct name 'name1' should be distinct at the subprogram level
+      !PORTABILITY: The construct name 'name1' should be distinct at the subprogram level [-Wno-benign-name-clash]
       name1: do k = 1, N
         !$acc parallel
         !ERROR: EXIT to construct 'fortname' outside of PARALLEL construct is not allowed
diff --git a/flang/test/Semantics/OpenACC/acc-data.f90 b/flang/test/Semantics/OpenACC/acc-data.f90
index 473b91d555cea..4b73c17b4f751 100644
--- a/flang/test/Semantics/OpenACC/acc-data.f90
+++ b/flang/test/Semantics/OpenACC/acc-data.f90
@@ -132,7 +132,7 @@ program openacc_data_validity
   !ERROR: At least one of COPYOUT, DELETE, DETACH clause must appear on the EXIT DATA directive
   !$acc exit data
 
-  !PORTABILITY: At least one of ATTACH, COPY, COPYIN, COPYOUT, CREATE, DEFAULT, DEVICEPTR, NO_CREATE, PRESENT clause should appear on the DATA directive
+  !PORTABILITY: At least one of ATTACH, COPY, COPYIN, COPYOUT, CREATE, DEFAULT, DEVICEPTR, NO_CREATE, PRESENT clause should appear on the DATA directive [-Wno-portability]
   !$acc data
   !$acc end data
 
diff --git a/flang/test/Semantics/OpenACC/acc-declare-validity.f90 b/flang/test/Semantics/OpenACC/acc-declare-validity.f90
index 7cdc69436704b..66592c47316c6 100644
--- a/flang/test/Semantics/OpenACC/acc-declare-validity.f90
+++ b/flang/test/Semantics/OpenACC/acc-declare-validity.f90
@@ -14,7 +14,7 @@ module openacc_declare_validity
 
   !$acc declare create(aa, bb)
 
-  !WARNING: 'aa' in the CREATE clause is already present in the same clause in this module
+  !WARNING: 'aa' in the CREATE clause is already present in the same clause in this module [-Wno-open-acc-usage]
   !$acc declare create(aa)
 
   !$acc declare link(ab)
diff --git a/flang/test/Semantics/OpenACC/acc-serial.f90 b/flang/test/Semantics/OpenACC/acc-serial.f90
index 1f22003ed6b11..c72c59512728a 100644
--- a/flang/test/Semantics/OpenACC/acc-serial.f90
+++ b/flang/test/Semantics/OpenACC/acc-serial.f90
@@ -84,15 +84,15 @@ program openacc_serial_validity
   !$acc serial wait(wait1) wait(wait2)
   !$acc end serial
 
-  !PORTABILITY: NUM_GANGS clause is not allowed on the SERIAL directive and will be ignored
+  !PORTABILITY: NUM_GANGS clause is not allowed on the SERIAL directive and will be ignored [-Wno-portability]
   !$acc serial num_gangs(8)
   !$acc end serial
 
-  !PORTABILITY: NUM_WORKERS clause is not allowed on the SERIAL directive and will be ignored
+  !PORTABILITY: NUM_WORKERS clause is not allowed on the SERIAL directive and will be ignored [-Wno-portability]
   !$acc serial num_workers(8)
   !$acc end serial
 
-  !PORTABILITY: VECTOR_LENGTH clause is not allowed on the SERIAL directive and will be ignored
+  !PORTABILITY: VECTOR_LENGTH clause is not allowed on the SERIAL directive and will be ignored [-Wno-portability]
   !$acc serial vector_length(128)
   !$acc end serial
 
diff --git a/flang/test/Semantics/OpenMP/allocate-align01.f90 b/flang/test/Semantics/OpenMP/allocate-align01.f90
index 4974f5e18397a..0ded38ec0bf16 100644
--- a/flang/test/Semantics/OpenMP/allocate-align01.f90
+++ b/flang/test/Semantics/OpenMP/allocate-align01.f90
@@ -13,7 +13,7 @@ program allocate_align_tree
     z = 3
     !ERROR: The alignment value should be a constant positive integer
 !$omp allocate(j) align(xx)
-    !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead.
+    !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead. [-Wno-open-mp-usage]
     !ERROR: The alignment value should be a constant positive integer
 !$omp allocate(xarray) align(-32) allocator(omp_large_cap_mem_alloc)
     allocate(j(z), xarray(t))
diff --git a/flang/test/Semantics/OpenMP/allocate01.f90 b/flang/test/Semantics/OpenMP/allocate01.f90
index 8a680eee743e0..fa8a062ee7fc8 100644
--- a/flang/test/Semantics/OpenMP/allocate01.f90
+++ b/flang/test/Semantics/OpenMP/allocate01.f90
@@ -19,7 +19,7 @@ subroutine sema()
     !$omp allocate(y)
         print *, a
 
-    !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead.
+    !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead. [-Wno-open-mp-usage]
     !ERROR: List items must be declared in the same scoping unit in which the ALLOCATE directive appears
     !$omp allocate(x) allocator(omp_default_mem_alloc)
       allocate ( x(a), darray(a, b) )
diff --git a/flang/test/Semantics/OpenMP/allocate02.f90 b/flang/test/Semantics/OpenMP/allocate02.f90
index 80ef60b31e700..0a03fffc644c7 100644
--- a/flang/test/Semantics/OpenMP/allocate02.f90
+++ b/flang/test/Semantics/OpenMP/allocate02.f90
@@ -16,11 +16,11 @@ subroutine allocate()
   !ERROR: At most one ALLOCATOR clause can appear on the ALLOCATE directive
   !$omp allocate(x, y) allocator(omp_default_mem_alloc) allocator(omp_default_mem_alloc)
 
-  !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead.
+  !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead. [-Wno-open-mp-usage]
   !$omp allocate(darray) allocator(omp_default_mem_alloc)
       allocate ( darray(a, b) )
 
-  !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead.
+  !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead. [-Wno-open-mp-usage]
   !ERROR: At most one ALLOCATOR clause can appear on the ALLOCATE directive
   !$omp allocate(darray) allocator(omp_default_mem_alloc) allocator(omp_default_mem_alloc)
       allocate ( darray(a, b) )
diff --git a/flang/test/Semantics/OpenMP/allocate03.f90 b/flang/test/Semantics/OpenMP/allocate03.f90
index b8c6b8e5dee77..4bf2c074965ed 100644
--- a/flang/test/Semantics/OpenMP/allocate03.f90
+++ b/flang/test/Semantics/OpenMP/allocate03.f90
@@ -18,7 +18,7 @@ subroutine allocate()
   !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the ALLOCATE directive
   !$omp allocate(my_var%array)
 
-  !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead.
+  !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead. [-Wno-open-mp-usage]
   !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the ALLOCATE directive
   !$omp allocate(darray, my_var%array) allocator(omp_default_mem_alloc)
     allocate ( darray(a, b) )
diff --git a/flang/test/Semantics/OpenMP/allocate05.f90 b/flang/test/Semantics/OpenMP/allocate05.f90
index 2c81c4dbc82c7..1bc2bd2a2581d 100644
--- a/flang/test/Semantics/OpenMP/allocate05.f90
+++ b/flang/test/Semantics/OpenMP/allocate05.f90
@@ -13,13 +13,13 @@ subroutine allocate()
   real, dimension (:,:), allocatable :: darray
 
   !$omp target
-      !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead.
+      !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead. [-Wno-open-mp-usage]
       !$omp allocate allocator(omp_default_mem_alloc)
           allocate ( darray(a, b) )
   !$omp end target
 
   !$omp target
-      !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead.
+      !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead. [-Wno-open-mp-usage]
       !ERROR: ALLOCATE directives that appear in a TARGET region must specify an allocator clause
       !$omp allocate
           allocate ( darray(a, b) )
diff --git a/flang/test/Semantics/OpenMP/allocate06.f90 b/flang/test/Semantics/OpenMP/allocate06.f90
index 7196bcac2b9b9..ced7267b771cd 100644
--- a/flang/test/Semantics/OpenMP/allocate06.f90
+++ b/flang/test/Semantics/OpenMP/allocate06.f90
@@ -14,7 +14,7 @@ subroutine allocate()
   !ERROR: List items specified in the ALLOCATE directive must not have the ALLOCATABLE attribute unless the directive is associated with an ALLOCATE statement
   !$omp allocate(darray) allocator(omp_default_mem_alloc)
 
-  !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead.
+  !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead. [-Wno-open-mp-usage]
   !$omp allocate(darray) allocator(omp_default_mem_alloc)
     allocate(darray(a, b))
 
diff --git a/flang/test/Semantics/OpenMP/allocate09.f90 b/flang/test/Semantics/OpenMP/allocate09.f90
index 645e97a3a33f3..7bea6da089916 100644
--- a/flang/test/Semantics/OpenMP/allocate09.f90
+++ b/flang/test/Semantics/OpenMP/allocate09.f90
@@ -12,28 +12,28 @@ subroutine allocate()
   integer, dimension(:), allocatable :: a, b, c, d, e, f, &
                                         g, h, i, j, k, l
 
-  !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead.
+  !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead. [-Wno-open-mp-usage]
   !$omp allocate(a) allocator(omp_default_mem_alloc)
     allocate(a(1), b(2))
 
-  !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead.
+  !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead. [-Wno-open-mp-usage]
   !$omp allocate(c, d) allocator(omp_default_mem_alloc)
     allocate(c(3), d(4))
 
   !$omp allocate(e) allocator(omp_default_mem_alloc)
   !$omp allocate(f, g) allocator(omp_default_mem_alloc)
-  !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead.
+  !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead. [-Wno-open-mp-usage]
   !$omp allocate
     allocate(e(5), f(6), g(7))
 
-  !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead.
+  !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead. [-Wno-open-mp-usage]
   !ERROR: Object 'i' in ALLOCATE directive not found in corresponding ALLOCATE statement
   !$omp allocate(h, i) allocator(omp_default_mem_alloc)
     allocate(h(8))
 
   !ERROR: Object 'j' in ALLOCATE directive not found in corresponding ALLOCATE statement
   !$omp allocate(j, k) allocator(omp_default_mem_alloc)
-  !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead.
+  !WARNING: OpenMP directive ALLOCATE has been deprecated, please use ALLOCATORS instead. [-Wno-open-mp-usage]
   !$omp allocate(l) allocator(omp_default_mem_alloc)
     allocate(k(9), l(10))
 
diff --git a/flang/test/Semantics/OpenMP/clause-validity01.f90 b/flang/test/Semantics/OpenMP/clause-validity01.f90
index 5e0d91914c441..22adfbc62a615 100644
--- a/flang/test/Semantics/OpenMP/clause-validity01.f90
+++ b/flang/test/Semantics/OpenMP/clause-validity01.f90
@@ -483,14 +483,14 @@
 ! 2.13.1 master
 
   !$omp parallel
-  !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+  !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead. [-Wno-open-mp-usage]
   !$omp master
   a=3.14
   !$omp end master
   !$omp end parallel
 
   !$omp parallel
-  !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+  !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead. [-Wno-open-mp-usage]
   !ERROR: NUM_THREADS clause is not allowed on the MASTER directive
   !$omp master num_threads(4)
   a=3.14
diff --git a/flang/test/Semantics/OpenMP/copying.f90 b/flang/test/Semantics/OpenMP/copying.f90
index 63fb39a0f26e5..4c6390a60ff9b 100644
--- a/flang/test/Semantics/OpenMP/copying.f90
+++ b/flang/test/Semantics/OpenMP/copying.f90
@@ -10,7 +10,7 @@
 subroutine firstprivate()
   class(*), allocatable, save :: x
 
-  !PORTABILITY: If a polymorphic variable with allocatable attribute 'x' is in FIRSTPRIVATE clause, the behavior is unspecified
+  !PORTABILITY: If a polymorphic variable with allocatable attribute 'x' is in FIRSTPRIVATE clause, the behavior is unspecified [-Wno-portability]
   !$omp parallel firstprivate(x)
     call sub()
   !$omp end parallel
@@ -20,7 +20,7 @@ subroutine firstprivate()
 subroutine lastprivate()
   class(*), allocatable, save :: x
 
-  !PORTABILITY: If a polymorphic variable with allocatable attribute 'x' is in LASTPRIVATE clause, the behavior is unspecified
+  !PORTABILITY: If a polymorphic variable with allocatable attribute 'x' is in LASTPRIVATE clause, the behavior is unspecified [-Wno-portability]
   !$omp do lastprivate(x)
   do i = 1, 10
     call sub()
@@ -33,7 +33,7 @@ subroutine copyin()
   class(*), allocatable, save :: x
   !$omp threadprivate(x)
 
-  !PORTABILITY: If a polymorphic variable with allocatable attribute 'x' is in COPYIN clause, the behavior is unspecified
+  !PORTABILITY: If a polymorphic variable with allocatable attribute 'x' is in COPYIN clause, the behavior is unspecified [-Wno-portability]
   !$omp parallel copyin(x)
     call sub()
   !$omp end parallel
@@ -46,7 +46,7 @@ subroutine copyprivate()
 
   !$omp single
     call sub()
-  !PORTABILITY: If a polymorphic variable with allocatable attribute 'x' is in COPYPRIVATE clause, the behavior is unspecified
+  !PORTABILITY: If a polymorphic variable with allocatable attribute 'x' is in COPYPRIVATE clause, the behavior is unspecified [-Wno-portability]
   !$omp end single copyprivate(x)
 
 end
diff --git a/flang/test/Semantics/OpenMP/declarative-directive01.f90 b/flang/test/Semantics/OpenMP/declarative-directive01.f90
index e8bf605565fad..52adb853e72c2 100644
--- a/flang/test/Semantics/OpenMP/declarative-directive01.f90
+++ b/flang/test/Semantics/OpenMP/declarative-directive01.f90
@@ -56,10 +56,10 @@ module m2
 contains
   subroutine foo
     !$omp declare target
-    !WARNING: The entity with PARAMETER attribute is used in a DECLARE TARGET directive
-    !WARNING: The entity with PARAMETER attribute is used in a DECLARE TARGET directive
+    !WARNING: The entity with PARAMETER attribute is used in a DECLARE TARGET directive [-Wno-open-mp-usage]
+    !WARNING: The entity with PARAMETER attribute is used in a DECLARE TARGET directive [-Wno-open-mp-usage]
     !$omp declare target (foo, N, M)
-    !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead.
+    !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
     !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
@@ -68,7 +68,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.
+    !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
     !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 the 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 0651d3b5d89c1..1151c1295f86c 100644
--- a/flang/test/Semantics/OpenMP/declare-target01.f90
+++ b/flang/test/Semantics/OpenMP/declare-target01.f90
@@ -51,84 +51,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.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !$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.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !$omp declare target to (my_var) device_type(host)
   
   !$omp declare target enter (my_var) device_type(host)
 
   !ERROR: A variable that is part of another variable (as an array or structure 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.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !$omp declare target to (my_var%t_i)
 
   !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
   !$omp declare target enter (my_var%t_i)
 
   !ERROR: A variable that is part of another variable (as an array or structure 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.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !$omp declare target to (my_var%t_arr)
 
   !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
   !$omp declare target enter (my_var%t_arr)
 
   !ERROR: A type parameter inquiry cannot appear on the DECLARE TARGET directive
-  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !$omp declare target to (my_var%kind_param)
 
   !ERROR: A type parameter inquiry cannot appear on the DECLARE TARGET directive
   !$omp declare target enter (my_var%kind_param)
 
   !ERROR: A type parameter inquiry cannot appear on the DECLARE TARGET directive
-  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !$omp declare target to (my_var%len_param)
 
   !ERROR: A type parameter inquiry cannot appear on the DECLARE TARGET directive
   !$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.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !$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.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !$omp declare target to (arr) device_type(nohost)
 
   !$omp declare target enter (arr) device_type(nohost)
 
   !ERROR: A variable that is part of another variable (as an array or structure 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.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !$omp declare target to (arr(1))
 
   !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
   !$omp declare target enter (arr(1))
 
   !ERROR: A variable that is part of another variable (as an array or structure 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.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !$omp declare target to (arr(1:2))
 
   !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
   !$omp declare target enter (arr(1:2))
 
   !ERROR: A type parameter inquiry cannot appear on the DECLARE TARGET directive
-  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !$omp declare target to (x%KIND)
 
   !ERROR: A type parameter inquiry cannot appear on the DECLARE TARGET directive
   !$omp declare target enter (x%KIND)
 
   !ERROR: A type parameter inquiry cannot appear on the DECLARE TARGET directive
-  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !$omp declare target to (w%LEN)
 
   !ERROR: A type parameter inquiry cannot appear on the DECLARE TARGET directive
   !$omp declare target enter (w%LEN)
 
   !ERROR: A type parameter inquiry cannot appear on the DECLARE TARGET directive
-  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !$omp declare target to (y%KIND)
 
   !ERROR: A type parameter inquiry cannot appear on the DECLARE TARGET directive
diff --git a/flang/test/Semantics/OpenMP/declare-target02.f90 b/flang/test/Semantics/OpenMP/declare-target02.f90
index 0f12180587f83..97161efa87547 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.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !$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.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !$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.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !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.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !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.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !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.
+    !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
     !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.
+    !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
     !$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.
+    !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
     !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.
+    !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
     !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.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !$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.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !$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.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !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.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !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.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !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.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !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-target03.f90 b/flang/test/Semantics/OpenMP/declare-target03.f90
index bb1ed90e390f3..4da00c91c967a 100644
--- a/flang/test/Semantics/OpenMP/declare-target03.f90
+++ b/flang/test/Semantics/OpenMP/declare-target03.f90
@@ -16,7 +16,7 @@ program main
   !ERROR: The module name or main program name cannot be in a DECLARE TARGET directive
   !$omp declare target (mod1)
 
-  !PORTABILITY: Name 'main' declared in a main program should not have the same name as the main program
+  !PORTABILITY: Name 'main' declared in a main program should not have the same name as the main program [-Wno-benign-name-clash]
   !ERROR: The module name or main program name cannot be in a DECLARE TARGET directive
   !$omp declare target (main)
 end
diff --git a/flang/test/Semantics/OpenMP/declare-target06.f90 b/flang/test/Semantics/OpenMP/declare-target06.f90
index 7df0a73123094..befee8d918efb 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.
+!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
 !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/deprecation.f90 b/flang/test/Semantics/OpenMP/deprecation.f90
index e04f43026bbce..13f65d1be98ff 100644
--- a/flang/test/Semantics/OpenMP/deprecation.f90
+++ b/flang/test/Semantics/OpenMP/deprecation.f90
@@ -4,7 +4,7 @@
 
 subroutine test_master()
   integer :: c = 1
-!WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+!WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead. [-Wno-open-mp-usage]
   !$omp master 
   c = c + 1
   !$omp end master
@@ -12,7 +12,7 @@ subroutine test_master()
 
 subroutine test_parallel_master
   integer :: c = 2
-!WARNING: OpenMP directive PARALLEL MASTER has been deprecated, please use PARALLEL MASKED instead.
+!WARNING: OpenMP directive PARALLEL MASTER has been deprecated, please use PARALLEL MASKED instead. [-Wno-open-mp-usage]
   !$omp parallel master
   c = c + 2
   !$omp end parallel master
@@ -20,7 +20,7 @@ subroutine test_parallel_master
 
 subroutine test_master_taskloop_simd()
   integer :: i, j = 1
-!WARNING: OpenMP directive MASTER TASKLOOP SIMD has been deprecated, please use MASKED TASKLOOP SIMD instead.
+!WARNING: OpenMP directive MASTER TASKLOOP SIMD has been deprecated, please use MASKED TASKLOOP SIMD instead. [-Wno-open-mp-usage]
   !$omp master taskloop simd 
   do i=1,10
    j = j + 1
@@ -30,7 +30,7 @@ subroutine test_master_taskloop_simd()
 
 subroutine test_master_taskloop
   integer :: i, j = 1
-!WARNING: OpenMP directive MASTER TASKLOOP has been deprecated, please use MASKED TASKLOOP instead.
+!WARNING: OpenMP directive MASTER TASKLOOP has been deprecated, please use MASKED TASKLOOP instead. [-Wno-open-mp-usage]
   !$omp master taskloop
   do i=1,10
    j = j + 1
@@ -40,7 +40,7 @@ subroutine test_master_taskloop
 
 subroutine test_parallel_master_taskloop_simd
   integer :: i, j = 1
-!WARNING: OpenMP directive PARALLEL MASTER TASKLOOP SIMD has been deprecated, please use PARALLEL_MASKED TASKLOOP SIMD instead.
+!WARNING: OpenMP directive PARALLEL MASTER TASKLOOP SIMD has been deprecated, please use PARALLEL_MASKED TASKLOOP SIMD instead. [-Wno-open-mp-usage]
   !$omp parallel master taskloop simd 
   do i=1,10
    j = j + 1
@@ -50,7 +50,7 @@ subroutine test_parallel_master_taskloop_simd
 
 subroutine test_parallel_master_taskloop
   integer :: i, j = 1
-!WARNING: OpenMP directive PARALLEL MASTER TASKLOOP has been deprecated, please use PARALLEL MASKED TASKLOOP instead.
+!WARNING: OpenMP directive PARALLEL MASTER TASKLOOP has been deprecated, please use PARALLEL MASKED TASKLOOP instead. [-Wno-open-mp-usage]
   !$omp parallel master taskloop
   do i=1,10
    j = j + 1
diff --git a/flang/test/Semantics/OpenMP/flush02.f90 b/flang/test/Semantics/OpenMP/flush02.f90
index 615332c6cf31c..d0be2edb651a6 100644
--- a/flang/test/Semantics/OpenMP/flush02.f90
+++ b/flang/test/Semantics/OpenMP/flush02.f90
@@ -78,7 +78,7 @@
 
   !$omp parallel num_threads(4)
     array = (/1, 2, 3, 4, 5, 6, 7, 8, 9, 10/)
-    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead. [-Wno-open-mp-usage]
     !$omp master
       !$omp flush (array)
     !$omp end master
diff --git a/flang/test/Semantics/OpenMP/nested-barrier.f90 b/flang/test/Semantics/OpenMP/nested-barrier.f90
index 5f51363d59e59..f9dd5bea0b75f 100644
--- a/flang/test/Semantics/OpenMP/nested-barrier.f90
+++ b/flang/test/Semantics/OpenMP/nested-barrier.f90
@@ -75,7 +75,7 @@ program omp_nest_barrier
   end do
   !$omp end critical
 
-  !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+  !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead. [-Wno-open-mp-usage]
   !$omp master
   do i = 1, 10
     k = k + 1
@@ -108,7 +108,7 @@ program omp_nest_barrier
   end do
   !$omp end ordered
 
-  !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+  !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead. [-Wno-open-mp-usage]
   !$omp master
   do i = 1, 10
     !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
diff --git a/flang/test/Semantics/OpenMP/nested-master.f90 b/flang/test/Semantics/OpenMP/nested-master.f90
index d51e366eb584b..e1497c95e9910 100644
--- a/flang/test/Semantics/OpenMP/nested-master.f90
+++ b/flang/test/Semantics/OpenMP/nested-master.f90
@@ -9,7 +9,7 @@ program omp_nest_master
   !$omp do
   do i = 1, 10
     k = k + 1
-    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead. [-Wno-open-mp-usage]
     !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
     !$omp master
     j = j -1
@@ -17,7 +17,7 @@ program omp_nest_master
   end do
 
   !$omp sections 
-  !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+  !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead. [-Wno-open-mp-usage]
   !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
     !$omp master
     do i = 1, 10
@@ -27,7 +27,7 @@ program omp_nest_master
   !$omp end sections
 
   !$omp single 
-  !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+  !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead. [-Wno-open-mp-usage]
   !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
     !$omp master
     do i = 1, 10
@@ -41,7 +41,7 @@ program omp_nest_master
   !$omp task
   do i = 1, 10
     k = k + 1
-    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead. [-Wno-open-mp-usage]
     !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
     !$omp master
     j = j -1
@@ -52,7 +52,7 @@ program omp_nest_master
   !$omp taskloop
   do i = 1, 10
     k = k + 1
-    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead. [-Wno-open-mp-usage]
     !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
     !$omp master
     j = j -1
@@ -63,7 +63,7 @@ program omp_nest_master
   !$omp target parallel do simd
   do i = 1, 10
     k = k + 1
-    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead. [-Wno-open-mp-usage]
     !ERROR: The only OpenMP constructs that can be encountered during execution of a 'SIMD' region are the `ATOMIC` construct, the `LOOP` construct, the `SIMD` construct, the `SCAN` construct and the `ORDERED` construct with the `SIMD` clause.
     !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
     !$omp master
@@ -75,7 +75,7 @@ program omp_nest_master
   !$omp critical
   do i = 1, 10
     k = k + 1
-    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead. [-Wno-open-mp-usage]
     !$omp master
     j = j -1
     !$omp end master
@@ -85,7 +85,7 @@ program omp_nest_master
   !$omp ordered
   do i = 1, 10
     k = k + 1
-    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead. [-Wno-open-mp-usage]
     !$omp master
     j = j -1
     !$omp end master
@@ -99,7 +99,7 @@ program omp_nest_master
     !$omp distribute
     do k =1, 10
       print *, "hello"
-      !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+      !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead. [-Wno-open-mp-usage]
       !$omp master
       j = j -1
       !$omp end master
@@ -116,7 +116,7 @@ program omp_nest_master
     !$omp distribute
     do k =1, 10
       print *, "hello"
-      !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+      !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead. [-Wno-open-mp-usage]
       !$omp master
       j = j -1
       !$omp end master
@@ -133,7 +133,7 @@ program omp_nest_master
     !$omp distribute
     do k =1, 10
       print *, "hello"
-      !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+      !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead. [-Wno-open-mp-usage]
       !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
       !$omp master
       j = j -1
@@ -151,7 +151,7 @@ program omp_nest_master
     !$omp distribute
     do k =1, 10
       print *, "hello"
-      !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+      !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead. [-Wno-open-mp-usage]
       !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
       !$omp master
       j = j -1
diff --git a/flang/test/Semantics/OpenMP/nested-target.f90 b/flang/test/Semantics/OpenMP/nested-target.f90
index 6a56a84f4f570..e1037bf132b16 100644
--- a/flang/test/Semantics/OpenMP/nested-target.f90
+++ b/flang/test/Semantics/OpenMP/nested-target.f90
@@ -10,7 +10,7 @@ program main
   real, allocatable :: B(:)
 
   !$omp target
-  !PORTABILITY: If TARGET UPDATE directive is nested inside TARGET region, the behaviour is unspecified
+  !PORTABILITY: If TARGET UPDATE directive is nested inside TARGET region, the behaviour is unspecified [-Wno-open-mp-usage]
   !$omp target update from(arrayA) to(arrayB)
   do i = 1, 512
     arrayA(i) = arrayB(i)
@@ -20,7 +20,7 @@ program main
   !$omp parallel
   !$omp target
   !$omp parallel
-  !PORTABILITY: If TARGET UPDATE directive is nested inside TARGET region, the behaviour is unspecified
+  !PORTABILITY: If TARGET UPDATE directive is nested inside TARGET region, the behaviour is unspecified [-Wno-open-mp-usage]
   !$omp target update from(arrayA) to(arrayB)
   do i = 1, 512
     arrayA(i) = arrayB(i)
@@ -30,7 +30,7 @@ program main
   !$omp end parallel
 
   !$omp target
-  !PORTABILITY: If TARGET DATA directive is nested inside TARGET region, the behaviour is unspecified
+  !PORTABILITY: If TARGET DATA directive is nested inside TARGET region, the behaviour is unspecified [-Wno-open-mp-usage]
   !$omp target data map(to: a)
   do i = 1, N
     a = 3.14
@@ -40,12 +40,12 @@ program main
 
   allocate(B(N))
   !$omp target
-  !PORTABILITY: If TARGET ENTER DATA directive is nested inside TARGET region, the behaviour is unspecified
+  !PORTABILITY: If TARGET ENTER DATA directive is nested inside TARGET region, the behaviour is unspecified [-Wno-open-mp-usage]
   !$omp target enter data map(alloc:B)
   !$omp end target
 
   !$omp target
-  !PORTABILITY: If TARGET EXIT DATA directive is nested inside TARGET region, the behaviour is unspecified
+  !PORTABILITY: If TARGET EXIT DATA directive is nested inside TARGET region, the behaviour is unspecified [-Wno-open-mp-usage]
   !$omp target exit data map(delete:B)
   !$omp end target
   deallocate(B)
@@ -53,7 +53,7 @@ program main
   n1 = 10
   n2 = 10
   !$omp target teams map(to:a)
-  !PORTABILITY: If TARGET DATA directive is nested inside TARGET region, the behaviour is unspecified
+  !PORTABILITY: If TARGET DATA directive is nested inside TARGET region, the behaviour is unspecified [-Wno-open-mp-usage]
   !ERROR: Only `DISTRIBUTE`, `PARALLEL`, or `LOOP` regions are allowed to be strictly nested inside `TEAMS` region.
   !$omp target data map(n1,n2)
   do i=1, n1
@@ -65,7 +65,7 @@ program main
   !$omp end target teams
 
   !$omp target teams map(to:a) map(from:n1,n2)
-  !PORTABILITY: If TARGET TEAMS DISTRIBUTE PARALLEL DO directive is nested inside TARGET region, the behaviour is unspecified
+  !PORTABILITY: If TARGET TEAMS DISTRIBUTE PARALLEL DO directive is nested inside TARGET region, the behaviour is unspecified [-Wno-open-mp-usage]
   !ERROR: Only `DISTRIBUTE`, `PARALLEL`, or `LOOP` regions are allowed to be strictly nested inside `TEAMS` region.
   !$omp target teams distribute parallel do
   do i=1, n1
diff --git a/flang/test/Semantics/OpenMP/nested-teams.f90 b/flang/test/Semantics/OpenMP/nested-teams.f90
index 974172ee97175..04b60e4ba9840 100644
--- a/flang/test/Semantics/OpenMP/nested-teams.f90
+++ b/flang/test/Semantics/OpenMP/nested-teams.f90
@@ -42,7 +42,7 @@ program main
   !$omp end teams
   end do
 
-  !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+  !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead. [-Wno-open-mp-usage]
   !$omp master
   !ERROR: TEAMS region can only be strictly nested within the implicit parallel region or TARGET region
   !$omp teams
diff --git a/flang/test/Semantics/OpenMP/ordered-simd.f90 b/flang/test/Semantics/OpenMP/ordered-simd.f90
index c90ffb3bd1c5f..1bdee73a34835 100644
--- a/flang/test/Semantics/OpenMP/ordered-simd.f90
+++ b/flang/test/Semantics/OpenMP/ordered-simd.f90
@@ -95,7 +95,7 @@ SUBROUTINE ORDERED_BAD(N)
 
   !$OMP CRITICAL  
     C =  C - A * B
-    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead. [-Wno-open-mp-usage]
     !$OMP MASTER
     DO I = 1,N
       !ERROR: `ORDERED` region may not be closely nested inside of `CRITICAL`, `ORDERED`, explicit `TASK` or `TASKLOOP` region.
@@ -108,7 +108,7 @@ SUBROUTINE ORDERED_BAD(N)
 
   !$OMP ORDERED  
     C =  C - A * B
-    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead. [-Wno-open-mp-usage]
     !$OMP MASTER
     DO I = 1,N
       !ERROR: `ORDERED` region may not be closely nested inside of `CRITICAL`, `ORDERED`, explicit `TASK` or `TASKLOOP` region.
@@ -121,7 +121,7 @@ SUBROUTINE ORDERED_BAD(N)
 
   !$OMP TASK  
     C =  C - A * B
-    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead. [-Wno-open-mp-usage]
     !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
     !$OMP MASTER
     DO I = 1,N
@@ -136,7 +136,7 @@ SUBROUTINE ORDERED_BAD(N)
   !$OMP TASKLOOP
   DO J= 1,N  
     C =  C - A * B
-    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead. [-Wno-open-mp-usage]
     !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
     !$OMP MASTER
     DO I = 1,N
diff --git a/flang/test/Semantics/OpenMP/parallel-master-goto.f90 b/flang/test/Semantics/OpenMP/parallel-master-goto.f90
index 72c8002ab4c59..9cb38d7138abd 100644
--- a/flang/test/Semantics/OpenMP/parallel-master-goto.f90
+++ b/flang/test/Semantics/OpenMP/parallel-master-goto.f90
@@ -7,7 +7,7 @@
 !ERROR: invalid branch leaving an OpenMP structured block
   goto 10
 end do
-!WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+!WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead. [-Wno-open-mp-usage]
 !$omp master
 10 print *, i
 !$omp end master
diff --git a/flang/test/Semantics/OpenMP/requires04.f90 b/flang/test/Semantics/OpenMP/requires04.f90
index 1fbb3aa6219bc..86fa63c6de8c3 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.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !$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 f410f0104d899..cb44c7301de97 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.
+  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wno-open-mp-usage]
   !$omp declare target to(f)
   !$omp declare target enter(f)
 end subroutine f
diff --git a/flang/test/Semantics/OpenMP/single03.f90 b/flang/test/Semantics/OpenMP/single03.f90
index dc2c2fd27eb04..11a14f5089ca5 100644
--- a/flang/test/Semantics/OpenMP/single03.f90
+++ b/flang/test/Semantics/OpenMP/single03.f90
@@ -39,7 +39,7 @@ subroutine omp_single
         !$omp single private(j) copyprivate(j)
             print *, "omp single", j
         !ERROR: COPYPRIVATE variable 'j' may not appear on a PRIVATE or FIRSTPRIVATE clause on a SINGLE construct
-        !WARNING: The COPYPRIVATE clause with 'j' is already used on the SINGLE directive
+        !WARNING: The COPYPRIVATE clause with 'j' is already used on the SINGLE directive [-Wno-open-mp-usage]
         !$omp end single copyprivate(j)
 
         !$omp single nowait
diff --git a/flang/test/Semantics/OpenMP/single04.f90 b/flang/test/Semantics/OpenMP/single04.f90
index 9505745c600e9..7585d04dcac63 100644
--- a/flang/test/Semantics/OpenMP/single04.f90
+++ b/flang/test/Semantics/OpenMP/single04.f90
@@ -52,20 +52,20 @@ program single
     !ERROR: NOWAIT clause must not be used with COPYPRIVATE clause on the SINGLE directive
     !$omp single copyprivate(x) nowait
         print *, x
-    !WARNING: The COPYPRIVATE clause with 'x' is already used on the SINGLE directive
+    !WARNING: The COPYPRIVATE clause with 'x' is already used on the SINGLE directive [-Wno-open-mp-usage]
     !ERROR: At most one NOWAIT clause can appear on the SINGLE directive
     !$omp end single copyprivate(x) nowait
 
     !$omp single copyprivate(x)
         print *, x
-    !WARNING: The COPYPRIVATE clause with 'x' is already used on the SINGLE directive
+    !WARNING: The COPYPRIVATE clause with 'x' is already used on the SINGLE directive [-Wno-open-mp-usage]
     !ERROR: NOWAIT clause must not be used with COPYPRIVATE clause on the SINGLE directive
     !$omp end single copyprivate(x) nowait
 
     !ERROR: NOWAIT clause must not be used with COPYPRIVATE clause on the SINGLE directive
     !$omp single copyprivate(x, y) nowait
         print *, x
-    !WARNING: The COPYPRIVATE clause with 'x' is already used on the SINGLE directive
+    !WARNING: The COPYPRIVATE clause with 'x' is already used on the SINGLE directive [-Wno-open-mp-usage]
     !ERROR: 'z' appears in more than one COPYPRIVATE clause on the END SINGLE directive
     !ERROR: At most one NOWAIT clause can appear on the SINGLE directive
     !$omp end single copyprivate(x, z) copyprivate(z) nowait
@@ -73,9 +73,9 @@ program single
     !ERROR: NOWAIT clause must not be used with COPYPRIVATE clause on the SINGLE directive
     !$omp single copyprivate(x) nowait copyprivate(y) copyprivate(z)
         print *, x
-    !WARNING: The COPYPRIVATE clause with 'x' is already used on the SINGLE directive
-    !WARNING: The COPYPRIVATE clause with 'y' is already used on the SINGLE directive
-    !WARNING: The COPYPRIVATE clause with 'z' is already used on the SINGLE directive
+    !WARNING: The COPYPRIVATE clause with 'x' is already used on the SINGLE directive [-Wno-open-mp-usage]
+    !WARNING: The COPYPRIVATE clause with 'y' is already used on the SINGLE directive [-Wno-open-mp-usage]
+    !WARNING: The COPYPRIVATE clause with 'z' is already used on the SINGLE directive [-Wno-open-mp-usage]
     !ERROR: At most one NOWAIT clause can appear on the SINGLE directive
     !$omp end single copyprivate(x, y, z) nowait
 end program
diff --git a/flang/test/Semantics/OpenMP/target01.f90 b/flang/test/Semantics/OpenMP/target01.f90
index 545cc8a7b69f8..86740a1bc401b 100644
--- a/flang/test/Semantics/OpenMP/target01.f90
+++ b/flang/test/Semantics/OpenMP/target01.f90
@@ -39,19 +39,19 @@ subroutine bar(b1, b2, b3)
   type(c_ptr), pointer :: b2
   type(c_ptr), value :: b3
 
-  !WARNING: Variable 'c' in IS_DEVICE_PTR clause must be a dummy argument. This semantic check is deprecated from OpenMP 5.2 and later.
+  !WARNING: Variable 'c' in IS_DEVICE_PTR clause must be a dummy argument. This semantic check is deprecated from OpenMP 5.2 and later. [-Wno-open-mp-usage]
   !$omp target is_device_ptr(c)
     y = y + 1
   !$omp end target
-  !WARNING: Variable 'b1' in IS_DEVICE_PTR clause must be a dummy argument that does not have the ALLOCATABLE, POINTER or VALUE attribute. This semantic check is deprecated from OpenMP 5.2 and later.
+  !WARNING: Variable 'b1' in IS_DEVICE_PTR clause must be a dummy argument that does not have the ALLOCATABLE, POINTER or VALUE attribute. This semantic check is deprecated from OpenMP 5.2 and later. [-Wno-open-mp-usage]
   !$omp target is_device_ptr(b1)
     y = y + 1
   !$omp end target
-  !WARNING: Variable 'b2' in IS_DEVICE_PTR clause must be a dummy argument that does not have the ALLOCATABLE, POINTER or VALUE attribute. This semantic check is deprecated from OpenMP 5.2 and later.
+  !WARNING: Variable 'b2' in IS_DEVICE_PTR clause must be a dummy argument that does not have the ALLOCATABLE, POINTER or VALUE attribute. This semantic check is deprecated from OpenMP 5.2 and later. [-Wno-open-mp-usage]
   !$omp target is_device_ptr(b2)
     y = y + 1
   !$omp end target
-  !WARNING: Variable 'b3' in IS_DEVICE_PTR clause must be a dummy argument that does not have the ALLOCATABLE, POINTER or VALUE attribute. This semantic check is deprecated from OpenMP 5.2 and later.
+  !WARNING: Variable 'b3' in IS_DEVICE_PTR clause must be a dummy argument that does not have the ALLOCATABLE, POINTER or VALUE attribute. This semantic check is deprecated from OpenMP 5.2 and later. [-Wno-open-mp-usage]
   !$omp target is_device_ptr(b3)
     y = y + 1
   !$omp end target
diff --git a/flang/test/Semantics/OpenMP/threadprivate03.f90 b/flang/test/Semantics/OpenMP/threadprivate03.f90
index b466a8e05e9c2..2696440c70e93 100644
--- a/flang/test/Semantics/OpenMP/threadprivate03.f90
+++ b/flang/test/Semantics/OpenMP/threadprivate03.f90
@@ -13,7 +13,7 @@ program main
   !ERROR: The module name or main program name cannot be in a THREADPRIVATE directive
   !$omp threadprivate(mod1)
 
-  !PORTABILITY: Name 'main' declared in a main program should not have the same name as the main program
+  !PORTABILITY: Name 'main' declared in a main program should not have the same name as the main program [-Wno-benign-name-clash]
   !ERROR: The module name or main program name cannot be in a THREADPRIVATE directive
   !$omp threadprivate(main)
 
diff --git a/flang/test/Semantics/OpenMP/use_device_ptr1.f90 b/flang/test/Semantics/OpenMP/use_device_ptr1.f90
index 5a5437e618450..54e53a6ef5bc8 100644
--- a/flang/test/Semantics/OpenMP/use_device_ptr1.f90
+++ b/flang/test/Semantics/OpenMP/use_device_ptr1.f90
@@ -27,7 +27,7 @@ subroutine omp_target_data
       a = arrayB
    !$omp end target data
 
-   !WARNING: Use of non-C_PTR type 'a' in USE_DEVICE_PTR is deprecated, use USE_DEVICE_ADDR instead
+   !WARNING: Use of non-C_PTR type 'a' in USE_DEVICE_PTR is deprecated, use USE_DEVICE_ADDR instead [-Wno-open-mp-usage]
    !$omp target data map(tofrom: a) use_device_ptr(a)
       a = 2
    !$omp end target data
diff --git a/flang/test/Semantics/allocate09.f90 b/flang/test/Semantics/allocate09.f90
index c6b3b58773b02..7f535c12481e8 100644
--- a/flang/test/Semantics/allocate09.f90
+++ b/flang/test/Semantics/allocate09.f90
@@ -85,9 +85,9 @@ subroutine C946(param_ca_4_assumed, param_ta_4_assumed, param_ca_4_deferred)
 
   allocate(deferredChar, source="abcd")
   allocate(deferredChar, mold=deferredChar)
-  !PORTABILITY: Character length of allocatable object in ALLOCATE should be the same as the SOURCE or MOLD
+  !PORTABILITY: Character length of allocatable object in ALLOCATE should be the same as the SOURCE or MOLD [-Wno-allocate-to-other-length]
   allocate(char2, source="a")
-  !PORTABILITY: Character length of allocatable object in ALLOCATE should be the same as the SOURCE or MOLD
+  !PORTABILITY: Character length of allocatable object in ALLOCATE should be the same as the SOURCE or MOLD [-Wno-allocate-to-other-length]
   allocate(char2, source="abc")
   allocate(char2, mold=deferredChar)
 
diff --git a/flang/test/Semantics/argshape01.f90 b/flang/test/Semantics/argshape01.f90
index 19cca1ca4620a..c1efb1000c501 100644
--- a/flang/test/Semantics/argshape01.f90
+++ b/flang/test/Semantics/argshape01.f90
@@ -113,7 +113,7 @@ program main
   !ERROR: Actual procedure argument has interface incompatible with dummy argument 's=': incompatible dummy argument #1: incompatible dummy data object shapes
   call s8c(s7)
   call s8c(s8)
-  !WARNING: Actual procedure argument has possible interface incompatibility with dummy argument 's=': possibly incompatible dummy argument #1: distinct dummy data object shapes
+  !WARNING: Actual procedure argument has possible interface incompatibility with dummy argument 's=': possibly incompatible dummy argument #1: distinct dummy data object shapes [-Wno-proc-dummy-arg-shapes]
   call s8c(s8b)
   call s9c(s9)
   call s9c(s9b)
@@ -154,7 +154,7 @@ program main
   !ERROR: Procedure pointer 'ps7' associated with incompatible procedure designator 's8': incompatible dummy argument #1: incompatible dummy data object shapes
   ps7 => s8
   ps8 => s8
-  !WARNING: pointer 'ps8' and s8b may not be completely compatible procedures: possibly incompatible dummy argument #1: distinct dummy data object shapes
+  !WARNING: pointer 'ps8' and s8b may not be completely compatible procedures: possibly incompatible dummy argument #1: distinct dummy data object shapes [-Wno-proc-dummy-arg-shapes]
   ps8 => s8b
   !ERROR: Procedure pointer 'ps8' associated with incompatible procedure designator 's6': incompatible dummy argument #1: incompatible dummy data object shapes
   ps8 => s6
diff --git a/flang/test/Semantics/assign02.f90 b/flang/test/Semantics/assign02.f90
index 9fa672025bfe7..2341488bbb2eb 100644
--- a/flang/test/Semantics/assign02.f90
+++ b/flang/test/Semantics/assign02.f90
@@ -85,7 +85,7 @@ subroutine s5
     real, pointer, volatile :: q
     p => x
     !ERROR: Pointer must be VOLATILE when target is a VOLATILE coarray
-    !ERROR: VOLATILE target associated with non-VOLATILE pointer
+    !ERROR: VOLATILE target associated with non-VOLATILE pointer [-Wno-non-volatile-pointer-to-volatile]
     p => y
     !ERROR: Pointer may not be VOLATILE when target is a non-VOLATILE coarray
     q => x
@@ -175,7 +175,7 @@ subroutine s12
     real, volatile, target :: x
     real, pointer :: p
     real, pointer, volatile :: q
-    !ERROR: VOLATILE target associated with non-VOLATILE pointer
+    !ERROR: VOLATILE target associated with non-VOLATILE pointer [-Wno-non-volatile-pointer-to-volatile]
     p => x
     q => x
   end
@@ -188,11 +188,11 @@ subroutine s13
     real, pointer, volatile :: q1
     type(t2), pointer, volatile :: q2
     type(t3), pointer, volatile :: q3
-    !ERROR: VOLATILE target associated with non-VOLATILE pointer
+    !ERROR: VOLATILE target associated with non-VOLATILE pointer [-Wno-non-volatile-pointer-to-volatile]
     p1 => y%t3Field%t2Field
-    !ERROR: VOLATILE target associated with non-VOLATILE pointer
+    !ERROR: VOLATILE target associated with non-VOLATILE pointer [-Wno-non-volatile-pointer-to-volatile]
     p2 => y%t3Field
-    !ERROR: VOLATILE target associated with non-VOLATILE pointer
+    !ERROR: VOLATILE target associated with non-VOLATILE pointer [-Wno-non-volatile-pointer-to-volatile]
     p3 => y
     !OK:
     q1 => y%t3Field%t2Field
@@ -200,9 +200,9 @@ subroutine s13
     q2 => y%t3Field
     !OK:
     q3 => y
-    !ERROR: VOLATILE target associated with non-VOLATILE pointer
+    !ERROR: VOLATILE target associated with non-VOLATILE pointer [-Wno-non-volatile-pointer-to-volatile]
     p3%t3FieldPtr => y%t3Field
-    !ERROR: VOLATILE target associated with non-VOLATILE pointer
+    !ERROR: VOLATILE target associated with non-VOLATILE pointer [-Wno-non-volatile-pointer-to-volatile]
     p3%t3FieldPtr%t2FieldPtr => y%t3Field%t2Field
     !OK
     q3%t3FieldPtr => y%t3Field
diff --git a/flang/test/Semantics/assign09.f90 b/flang/test/Semantics/assign09.f90
index b29e67a473e13..09ec3683b1dd0 100644
--- a/flang/test/Semantics/assign09.f90
+++ b/flang/test/Semantics/assign09.f90
@@ -49,9 +49,9 @@ elemental real function userElemental(a)
   realToRealProcPtr => noInterfaceExternal ! ok
   intToRealProcPtr => noInterfaceExternal !ok
   call sub1(noInterfaceExternal) ! ok
-  !WARNING: Actual procedure argument has an implicit interface which is not known to be compatible with dummy argument 'p=' which has an explicit interface
+  !WARNING: Actual procedure argument has an implicit interface which is not known to be compatible with dummy argument 'p=' which has an explicit interface [-Wno-implicit-interface-actual]
   call sub2(noInterfaceExternal)
-  !WARNING: Actual procedure argument has an implicit interface which is not known to be compatible with dummy argument 'p=' which has an explicit interface
+  !WARNING: Actual procedure argument has an implicit interface which is not known to be compatible with dummy argument 'p=' which has an explicit interface [-Wno-implicit-interface-actual]
   call sub3(noInterfaceExternal)
 
   !ERROR: Procedure pointer 'nointerfaceprocptr' with implicit interface may not be associated with procedure designator 'userelemental' with explicit interface that cannot be called via an implicit interface
diff --git a/flang/test/Semantics/associate01.f90 b/flang/test/Semantics/associate01.f90
index deafea695e84f..7d074ce040353 100644
--- a/flang/test/Semantics/associate01.f90
+++ b/flang/test/Semantics/associate01.f90
@@ -13,7 +13,7 @@ module m1
   function iptr(n)
     integer, intent(in), target :: n
     integer, pointer :: iptr
-    !WARNING: Pointer target is not a definable variable
+    !WARNING: Pointer target is not a definable variable [-Wno-pointer-to-undefinable]
     !BECAUSE: 'n' is an INTENT(IN) dummy argument
     iptr => n
   end function
diff --git a/flang/test/Semantics/associated.f90 b/flang/test/Semantics/associated.f90
index 3f3f5488ad9fe..59eedbbe2d98f 100644
--- a/flang/test/Semantics/associated.f90
+++ b/flang/test/Semantics/associated.f90
@@ -123,15 +123,15 @@ subroutine test(assumedRank)
     lVar = associated(null(intAllocVar))
     lVar = associated(null()) !OK
     lVar = associated(null(intPointerVar1)) !OK
-    !PORTABILITY: POINTER= argument of ASSOCIATED() is required by some other compilers to be a valid left-hand side of a pointer assignment statement
+    !PORTABILITY: POINTER= argument of ASSOCIATED() is required by some other compilers to be a valid left-hand side of a pointer assignment statement [-Wno-portability]
     !BECAUSE: 'NULL()' is a null pointer
     lVar = associated(null(), null()) !OK
     lVar = associated(intPointerVar1, null(intPointerVar2)) !OK
     lVar = associated(intPointerVar1, null()) !OK
-    !PORTABILITY: POINTER= argument of ASSOCIATED() is required by some other compilers to be a valid left-hand side of a pointer assignment statement
+    !PORTABILITY: POINTER= argument of ASSOCIATED() is required by some other compilers to be a valid left-hand side of a pointer assignment statement [-Wno-portability]
     !BECAUSE: 'NULL()' is a null pointer
     lVar = associated(null(), null(intPointerVar1)) !OK
-    !PORTABILITY: POINTER= argument of ASSOCIATED() is required by some other compilers to be a pointer
+    !PORTABILITY: POINTER= argument of ASSOCIATED() is required by some other compilers to be a pointer [-Wno-portability]
     lVar = associated(null(intPointerVar1), null()) !OK
     !ERROR: POINTER= argument of ASSOCIATED() must be a pointer
     lVar = associated(intVar)
@@ -180,18 +180,18 @@ subroutine test(assumedRank)
 
     ! Functions (other than NULL) returning pointers
     lVar = associated(objPtrFunc(targetIntVar1)) ! ok
-    !PORTABILITY: POINTER= argument of ASSOCIATED() is required by some other compilers to be a pointer
+    !PORTABILITY: POINTER= argument of ASSOCIATED() is required by some other compilers to be a pointer [-Wno-portability]
     lVar = associated(objPtrFunc(targetIntVar1), targetIntVar1) ! ok
-    !PORTABILITY: POINTER= argument of ASSOCIATED() is required by some other compilers to be a pointer
+    !PORTABILITY: POINTER= argument of ASSOCIATED() is required by some other compilers to be a pointer [-Wno-portability]
     lVar = associated(objPtrFunc(targetIntVar1), objPtrFunc(targetIntVar1)) ! ok
     lVar = associated(procPtrFunc()) ! ok
     lVar = associated(procPtrFunc(), intFunc) ! ok
     lVar = associated(procPtrFunc(), procPtrFunc()) ! ok
     !ERROR: POINTER= argument 'objptrfunc(targetintvar1)' is an object pointer but the TARGET= argument 'intfunc' is not a variable
-    !PORTABILITY: POINTER= argument of ASSOCIATED() is required by some other compilers to be a pointer
+    !PORTABILITY: POINTER= argument of ASSOCIATED() is required by some other compilers to be a pointer [-Wno-portability]
     lVar = associated(objPtrFunc(targetIntVar1), intFunc)
     !ERROR: POINTER= argument 'objptrfunc(targetintvar1)' is an object pointer but the TARGET= argument 'procptrfunc()' is not a variable
-    !PORTABILITY: POINTER= argument of ASSOCIATED() is required by some other compilers to be a pointer
+    !PORTABILITY: POINTER= argument of ASSOCIATED() is required by some other compilers to be a pointer [-Wno-portability]
     lVar = associated(objPtrFunc(targetIntVar1), procPtrFunc())
     !ERROR: POINTER= argument 'procptrfunc()' is a procedure pointer but the TARGET= argument 'objptrfunc(targetintvar1)' is not a procedure or procedure pointer
     lVar = associated(procPtrFunc(), objPtrFunc(targetIntVar1))
diff --git a/flang/test/Semantics/bind-c02.f90 b/flang/test/Semantics/bind-c02.f90
index 416d071542fe6..fcb95c5feb727 100644
--- a/flang/test/Semantics/bind-c02.f90
+++ b/flang/test/Semantics/bind-c02.f90
@@ -19,8 +19,8 @@ subroutine proc()
   !ERROR: Only variable and named common block can be in BIND statement
   bind(c) :: sub
 
-  !PORTABILITY: Global name 'm' conflicts with a module
-  !PORTABILITY: Name 'm' declared in a module should not have the same name as the module
+  !PORTABILITY: Global name 'm' conflicts with a module [-Wno-benign-name-clash]
+  !PORTABILITY: Name 'm' declared in a module should not have the same name as the module [-Wno-benign-name-clash]
   bind(c) :: m ! no error for implicit type variable
 
   type my_type
diff --git a/flang/test/Semantics/bind-c04.f90 b/flang/test/Semantics/bind-c04.f90
index 27119e375ce05..0d79dc155a92f 100644
--- a/flang/test/Semantics/bind-c04.f90
+++ b/flang/test/Semantics/bind-c04.f90
@@ -37,7 +37,7 @@ subroutine aproc2() bind(c) ! ok
 
   procedure(proc), bind(c) :: y
 
-  !WARNING: Attribute 'BIND(C)' cannot be used more than once
+  !WARNING: Attribute 'BIND(C)' cannot be used more than once [-Wno-redundant-attribute]
   !ERROR: A procedure pointer may not have a BIND attribute with a name
   procedure(proc), bind(c, name="pc8"), bind(c), pointer :: pc8
 
diff --git a/flang/test/Semantics/bind-c06.f90 b/flang/test/Semantics/bind-c06.f90
index ff78a4743deee..b35b5075a229f 100644
--- a/flang/test/Semantics/bind-c06.f90
+++ b/flang/test/Semantics/bind-c06.f90
@@ -40,7 +40,7 @@ program main
     procedure, nopass :: b => s
   end type
 
-  ! WARNING: A derived type with the BIND attribute should not be empty
+  ! WARNING: A derived type with the BIND attribute should not be empty [-Wno-empty-bind-c-derived-type]
   type, bind(c) :: t5
   end type
 
@@ -71,7 +71,7 @@ program main
   end type
 
   type, bind(c) :: t10
-    !WARNING: A CHARACTER component of an interoperable type should have length 1
+    !WARNING: A CHARACTER component of an interoperable type should have length 1 [-Wno-bind-c-char-length]
     character(len=2) x
   end type
   type, bind(c) :: t11
@@ -79,7 +79,7 @@ program main
     character(kind=2) x
   end type
   type, bind(c) :: t12
-    !PORTABILITY: A LOGICAL component of an interoperable type should have the interoperable KIND=C_BOOL
+    !PORTABILITY: A LOGICAL component of an interoperable type should have the interoperable KIND=C_BOOL [-Wno-logical-vs-c-bool]
     logical(kind=8) x
   end type
   type, bind(c) :: t13
diff --git a/flang/test/Semantics/bind-c11.f90 b/flang/test/Semantics/bind-c11.f90
index 54021f68b3d8d..e74adef186c09 100644
--- a/flang/test/Semantics/bind-c11.f90
+++ b/flang/test/Semantics/bind-c11.f90
@@ -8,7 +8,7 @@ module m
   real, allocatable, bind(c) :: x3(:)
  contains
   subroutine s1(x) bind(c)
-    !PORTABILITY: A BIND(C) LOGICAL dummy argument should have the interoperable KIND=C_BOOL
+    !PORTABILITY: A BIND(C) LOGICAL dummy argument should have the interoperable KIND=C_BOOL [-Wno-logical-vs-c-bool]
     logical(2), intent(in), value :: x
   end
   subroutine s2(x) bind(c)
diff --git a/flang/test/Semantics/bind-c13.f90 b/flang/test/Semantics/bind-c13.f90
index 81815c1a95efa..6798bbb08b3f3 100644
--- a/flang/test/Semantics/bind-c13.f90
+++ b/flang/test/Semantics/bind-c13.f90
@@ -5,8 +5,8 @@ subroutine interop(ptr,ashape,arank,eshape,asize) bind(c)
   real, pointer, contiguous :: ptr(:)
   real, contiguous :: ashape(:) ! ok
   real, contiguous :: arank(..) ! ok
-  !PORTABILITY: CONTIGUOUS entity 'eshape' should be an array pointer, assumed-shape, or assumed-rank
+  !PORTABILITY: CONTIGUOUS entity 'eshape' should be an array pointer, assumed-shape, or assumed-rank [-Wno-redundant-contiguous]
   real, contiguous :: eshape(10)
-  !PORTABILITY: CONTIGUOUS entity 'asize' should be an array pointer, assumed-shape, or assumed-rank
+  !PORTABILITY: CONTIGUOUS entity 'asize' should be an array pointer, assumed-shape, or assumed-rank [-Wno-redundant-contiguous]
   real, contiguous :: asize(*)
 end
diff --git a/flang/test/Semantics/bind-c17.f90 b/flang/test/Semantics/bind-c17.f90
index 8e0ecde67a0a5..9c33292342311 100644
--- a/flang/test/Semantics/bind-c17.f90
+++ b/flang/test/Semantics/bind-c17.f90
@@ -4,7 +4,7 @@ module m
   end type
  contains
   subroutine sub(x) bind(c)
-    !PORTABILITY: The derived type of this interoperable object should be BIND(C)
+    !PORTABILITY: The derived type of this interoperable object should be BIND(C) [-Wno-portability]
     type(a), pointer, intent(in) :: x
   end
 end
diff --git a/flang/test/Semantics/bindings01.f90 b/flang/test/Semantics/bindings01.f90
index dc44db09c4a6f..f47acacbcd5a3 100644
--- a/flang/test/Semantics/bindings01.f90
+++ b/flang/test/Semantics/bindings01.f90
@@ -4,7 +4,7 @@
 
 module m
   !ERROR: An ABSTRACT derived type must be extensible
-  !PORTABILITY: A derived type with the BIND attribute should not be empty
+  !PORTABILITY: A derived type with the BIND attribute should not be empty [-Wno-empty-bind-c-derived-type]
   type, abstract, bind(c) :: badAbstract1
   end type
   !ERROR: An ABSTRACT derived type must be extensible
@@ -45,7 +45,7 @@ module m
   end type
   type, extends(intermediate) :: concrete2  ! ensure no false missing binding error
   end type
-  !WARNING: A derived type with the BIND attribute should not be empty
+  !WARNING: A derived type with the BIND attribute should not be empty [-Wno-empty-bind-c-derived-type]
   type, bind(c) :: inextensible1
   end type
   !ERROR: The parent type is not extensible
@@ -226,7 +226,7 @@ subroutine mysubr
   end subroutine
   subroutine test
     type(t) a(2)
-    !PORTABILITY: Base of NOPASS type-bound procedure reference should be scalar
+    !PORTABILITY: Base of NOPASS type-bound procedure reference should be scalar [-Wno-nopass-scalar-base]
     call a%tbp
     !ERROR: Base of procedure component reference must be scalar
     call a%pp
diff --git a/flang/test/Semantics/bindings03.f90 b/flang/test/Semantics/bindings03.f90
index baa8432a2701e..d767327e9447f 100644
--- a/flang/test/Semantics/bindings03.f90
+++ b/flang/test/Semantics/bindings03.f90
@@ -15,9 +15,9 @@ program test
   use m
   procedure(sub), pointer :: p
   type(t) x
-  !PORTABILITY: Procedure binding 'sub' used as target of a pointer assignment
+  !PORTABILITY: Procedure binding 'sub' used as target of a pointer assignment [-Wno-binding-as-procedure]
   p => x%sub
-  !PORTABILITY: Procedure binding 'sub' passed as an actual argument
+  !PORTABILITY: Procedure binding 'sub' passed as an actual argument [-Wno-binding-as-procedure]
   call sub2(x%sub)
  contains
   subroutine sub2(s)
diff --git a/flang/test/Semantics/block-data01.f90 b/flang/test/Semantics/block-data01.f90
index aa4ede787c17a..53d7a460ed4bc 100644
--- a/flang/test/Semantics/block-data01.f90
+++ b/flang/test/Semantics/block-data01.f90
@@ -7,7 +7,7 @@ block data foo
   !ERROR: An initialized variable in BLOCK DATA must be in a COMMON block
   integer :: notInCommon = 1
   integer :: uninitialized ! ok
-  !PORTABILITY: Procedure pointer 'q' should not have an ELEMENTAL intrinsic as its interface
+  !PORTABILITY: Procedure pointer 'q' should not have an ELEMENTAL intrinsic as its interface [-Wno-portability]
   !ERROR: 'q' may not appear in a BLOCK DATA subprogram
   procedure(sin), pointer :: q => cos
   !ERROR: 'p' may not be a procedure as it is in a COMMON block
diff --git a/flang/test/Semantics/boz-literal-constants.f90 b/flang/test/Semantics/boz-literal-constants.f90
index ee6919cb9ecd5..94cf84f1e556c 100644
--- a/flang/test/Semantics/boz-literal-constants.f90
+++ b/flang/test/Semantics/boz-literal-constants.f90
@@ -56,7 +56,7 @@ subroutine explicit(n, x, c)
   res = CMPLX (realpart, img, 4)
   res = CMPLX (B"0101", B"1111", 4)
 
-  !WARNING: underflow on REAL(8) to REAL(4) conversion
+  !WARNING: underflow on REAL(8) to REAL(4) conversion [-Wno-folding-exception]
   dbl = DBLE(B"1111")
   dbl = DBLE(realpart)
 
diff --git a/flang/test/Semantics/c7108.f90 b/flang/test/Semantics/c7108.f90
index c23a0abe3ee03..8b19c3dc03216 100644
--- a/flang/test/Semantics/c7108.f90
+++ b/flang/test/Semantics/c7108.f90
@@ -33,9 +33,9 @@ program p
   use m
   type(foo) x
   x = foo(); print *, x       ! ok, not ambiguous
-  !PORTABILITY: Reference to generic function 'foo' (resolving to specific 'bar0') is ambiguous with a structure constructor of the same name
+  !PORTABILITY: Reference to generic function 'foo' (resolving to specific 'bar0') is ambiguous with a structure constructor of the same name [-Wno-ambiguous-structure-constructor]
   x = foo(2); print *, x      ! ambigous
-  !PORTABILITY: Reference to generic function 'foo' (resolving to specific 'bar2') is ambiguous with a structure constructor of the same name
+  !PORTABILITY: Reference to generic function 'foo' (resolving to specific 'bar2') is ambiguous with a structure constructor of the same name [-Wno-ambiguous-structure-constructor]
   x = foo(3.); print *, x     ! ambiguous due to data conversion
   x = foo(.true.); print *, x ! ok, not ambigous
 end
diff --git a/flang/test/Semantics/c_f_pointer.f90 b/flang/test/Semantics/c_f_pointer.f90
index de5673f8dc1d9..1c21862a5537e 100644
--- a/flang/test/Semantics/c_f_pointer.f90
+++ b/flang/test/Semantics/c_f_pointer.f90
@@ -46,12 +46,12 @@ program test
   call c_f_pointer(scalarC, multiDimIntF, shape=[1_8])
   !ERROR: SHAPE= argument to C_F_POINTER() must be a rank-one array.
   call c_f_pointer(scalarC, multiDimIntF, shape=rankTwoArray)
-  !WARNING: FPTR= argument to C_F_POINTER() should not be unlimited polymorphic
+  !WARNING: FPTR= argument to C_F_POINTER() should not be unlimited polymorphic [-Wno-interoperability]
   call c_f_pointer(scalarC, unlimited)
-  !PORTABILITY: FPTR= argument to C_F_POINTER() should not have a derived type that is not BIND(C)
+  !PORTABILITY: FPTR= argument to C_F_POINTER() should not have a derived type that is not BIND(C) [-Wno-portability]
   call c_f_pointer(scalarC, notBindC)
-  !WARNING: FPTR= argument to C_F_POINTER() should not have the non-interoperable character length CHARACTER(KIND=1,LEN=2_8)
+  !WARNING: FPTR= argument to C_F_POINTER() should not have the non-interoperable character length CHARACTER(KIND=1,LEN=2_8) [-Wno-character-interoperability]
   call c_f_pointer(scalarC, c2ptr)
-  !WARNING: FPTR= argument to C_F_POINTER() should not have the non-interoperable intrinsic type or kind CHARACTER(KIND=4,LEN=1_8)
+  !WARNING: FPTR= argument to C_F_POINTER() should not have the non-interoperable intrinsic type or kind CHARACTER(KIND=4,LEN=1_8) [-Wno-interoperability]
   call c_f_pointer(scalarC, unicodePtr)
 end program
diff --git a/flang/test/Semantics/c_loc01.f90 b/flang/test/Semantics/c_loc01.f90
index a515a7a64f02a..27559a402aba4 100644
--- a/flang/test/Semantics/c_loc01.f90
+++ b/flang/test/Semantics/c_loc01.f90
@@ -14,7 +14,7 @@ subroutine test(assumedType, poly, nclen, n)
     type(c_ptr) cp
     type(c_funptr) cfp
     real notATarget
-    !PORTABILITY: Procedure pointer 'pptr' should not have an ELEMENTAL intrinsic as its interface
+    !PORTABILITY: Procedure pointer 'pptr' should not have an ELEMENTAL intrinsic as its interface [-Wno-portability]
     procedure(sin), pointer :: pptr
     real, target :: arr(3)
     type(hasLen(1)), target :: clen
@@ -41,9 +41,9 @@ subroutine test(assumedType, poly, nclen, n)
     cp = c_loc(nclen)
     !ERROR: C_LOC() argument may not be zero-length character
     cp = c_loc(ch(2:1))
-    !WARNING: C_LOC() argument has non-interoperable character length
+    !WARNING: C_LOC() argument has non-interoperable character length [-Wno-character-interoperability]
     cp = c_loc(ch)
-    !WARNING: C_LOC() argument has non-interoperable intrinsic type or kind
+    !WARNING: C_LOC() argument has non-interoperable intrinsic type or kind [-Wno-interoperability]
     cp = c_loc(unicode)
     cp = c_loc(ch(1:1)) ! ok
     cp = c_loc(deferred) ! ok
diff --git a/flang/test/Semantics/call01.f90 b/flang/test/Semantics/call01.f90
index 67d14c3800671..862677ef0bb4a 100644
--- a/flang/test/Semantics/call01.f90
+++ b/flang/test/Semantics/call01.f90
@@ -119,16 +119,16 @@ end function nested
 end function
 
 subroutine s01(f1, f2, fp1, fp2, fp3)
-  !PORTABILITY: A dummy procedure pointer should not have assumed-length CHARACTER(*) result type
+  !PORTABILITY: A dummy procedure pointer should not have assumed-length CHARACTER(*) result type [-Wno-portability]
   character*(*) :: f1, f3, fp1
   external :: f1, f3
   pointer :: fp1, fp3
-  !PORTABILITY: A dummy procedure pointer should not have assumed-length CHARACTER(*) result type
+  !PORTABILITY: A dummy procedure pointer should not have assumed-length CHARACTER(*) result type [-Wno-portability]
   procedure(character*(*)), pointer :: fp2
   interface
     character*(*) function f2()
     end function
-    !PORTABILITY: A dummy procedure pointer should not have assumed-length CHARACTER(*) result type
+    !PORTABILITY: A dummy procedure pointer should not have assumed-length CHARACTER(*) result type [-Wno-portability]
     character*(*) function fp3()
     end function
     !ERROR: A function interface may not declare an assumed-length CHARACTER(*) result
diff --git a/flang/test/Semantics/call02.f90 b/flang/test/Semantics/call02.f90
index 0ec5530f98089..e843b006dd2fc 100644
--- a/flang/test/Semantics/call02.f90
+++ b/flang/test/Semantics/call02.f90
@@ -8,7 +8,7 @@ elemental real function elem(x)
       real, intent(in), value :: x
     end function
     subroutine subr(dummy)
-      !PORTABILITY: A dummy procedure should not have an ELEMENTAL intrinsic as its interface
+      !PORTABILITY: A dummy procedure should not have an ELEMENTAL intrinsic as its interface [-Wno-portability]
       procedure(sin) :: dummy
     end subroutine
     subroutine badsubr(dummy)
@@ -17,11 +17,11 @@ subroutine badsubr(dummy)
       procedure(elem) :: dummy
     end subroutine
     subroutine optionalsubr(dummy)
-      !PORTABILITY: A dummy procedure should not have an ELEMENTAL intrinsic as its interface
+      !PORTABILITY: A dummy procedure should not have an ELEMENTAL intrinsic as its interface [-Wno-portability]
       procedure(sin), optional :: dummy
     end subroutine
     subroutine ptrsubr(dummy)
-      !PORTABILITY: A dummy procedure should not have an ELEMENTAL intrinsic as its interface
+      !PORTABILITY: A dummy procedure should not have an ELEMENTAL intrinsic as its interface [-Wno-portability]
       procedure(sin), pointer, intent(in) :: dummy
     end subroutine
   end interface
diff --git a/flang/test/Semantics/call03.f90 b/flang/test/Semantics/call03.f90
index 59513557324e5..398c587792218 100644
--- a/flang/test/Semantics/call03.f90
+++ b/flang/test/Semantics/call03.f90
@@ -163,9 +163,9 @@ subroutine test06 ! 15.5.2.4(4)
     type(pdtWithDefault(3)) :: defaultVar3
     type(pdtWithDefault(4)) :: defaultVar4
     character :: ch1
-    !ERROR: Actual argument variable length '1' is less than expected length '2'
+    !ERROR: Actual argument variable length '1' is less than expected length '2' [-Wno-short-character-actual]
     call ch2(ch1)
-    !WARNING: Actual argument expression length '0' is less than expected length '2'
+    !WARNING: Actual argument expression length '0' is less than expected length '2' [-Wno-short-character-actual]
     call ch2("")
     call pdtdefault(vardefault)
     !ERROR: Actual argument type 'pdt(n=3_4)' is not compatible with dummy argument type 'pdt'
@@ -300,10 +300,10 @@ subroutine test12 ! 15.5.2.4(21)
     !ERROR: Actual argument associated with INTENT(IN OUT) dummy argument 'x=' is not definable
     !BECAUSE: Variable 'a(int(j,kind=8))' has a vector subscript
     call intentinout_arr(a(j))
-    !WARNING: Actual argument associated with ASYNCHRONOUS dummy argument 'x=' is not definable
+    !WARNING: Actual argument associated with ASYNCHRONOUS dummy argument 'x=' is not definable [-Wno-undefinable-asynchronous-or-volatile-actual]
     !BECAUSE: Variable 'a(int(j,kind=8))' has a vector subscript
     call asynchronous_arr(a(j))
-    !WARNING: Actual argument associated with VOLATILE dummy argument 'x=' is not definable
+    !WARNING: Actual argument associated with VOLATILE dummy argument 'x=' is not definable [-Wno-undefinable-asynchronous-or-volatile-actual]
     !BECAUSE: Variable 'a(int(j,kind=8))' has a vector subscript
     call volatile_arr(a(j))
   end subroutine
@@ -386,9 +386,9 @@ subroutine test16() ! C1540
     call contiguous(a) ! ok
     call pointer(a) ! ok
     call pointer(b) ! ok
-    !ERROR: VOLATILE target associated with non-VOLATILE pointer
+    !ERROR: VOLATILE target associated with non-VOLATILE pointer [-Wno-non-volatile-pointer-to-volatile]
     call pointer(c) ! ok
-    !ERROR: VOLATILE target associated with non-VOLATILE pointer
+    !ERROR: VOLATILE target associated with non-VOLATILE pointer [-Wno-non-volatile-pointer-to-volatile]
     call pointer(d) ! ok
     call valueassumedsize(a) ! ok
     call valueassumedsize(b) ! ok
diff --git a/flang/test/Semantics/call05.f90 b/flang/test/Semantics/call05.f90
index a06fe4f196c8c..50b585a88a8e8 100644
--- a/flang/test/Semantics/call05.f90
+++ b/flang/test/Semantics/call05.f90
@@ -73,9 +73,9 @@ subroutine test
     call sma(ma) ! ok
     call spp(pp) ! ok
     call spa(pa) ! ok
-    !PORTABILITY: If a POINTER or ALLOCATABLE actual argument is polymorphic, the corresponding dummy argument should also be so
+    !PORTABILITY: If a POINTER or ALLOCATABLE actual argument is polymorphic, the corresponding dummy argument should also be so [-Wno-polymorphic-actual-allocatable-or-pointer-to-monomorphic-dummy]
     call smp(pp)
-    !PORTABILITY: If a POINTER or ALLOCATABLE actual argument is polymorphic, the corresponding dummy argument should also be so
+    !PORTABILITY: If a POINTER or ALLOCATABLE actual argument is polymorphic, the corresponding dummy argument should also be so [-Wno-polymorphic-actual-allocatable-or-pointer-to-monomorphic-dummy]
     call sma(pa)
     !ERROR: If a POINTER or ALLOCATABLE dummy or actual argument is polymorphic, both must be so
     call spp(mp)
diff --git a/flang/test/Semantics/call07.f90 b/flang/test/Semantics/call07.f90
index 92f2bdba882d5..76850e90d3af2 100644
--- a/flang/test/Semantics/call07.f90
+++ b/flang/test/Semantics/call07.f90
@@ -19,17 +19,17 @@ subroutine s04(p)
   end subroutine
 
   subroutine test
-    !PORTABILITY: CONTIGUOUS entity 'a01' should be an array pointer, assumed-shape, or assumed-rank
+    !PORTABILITY: CONTIGUOUS entity 'a01' should be an array pointer, assumed-shape, or assumed-rank [-Wno-redundant-contiguous]
     real, pointer, contiguous :: a01 ! C830
     real, pointer :: a02(:)
     real, target :: a03(10)
     real :: a04(10) ! not TARGET
-    !PORTABILITY: CONTIGUOUS entity 'scalar' should be an array pointer, assumed-shape, or assumed-rank
+    !PORTABILITY: CONTIGUOUS entity 'scalar' should be an array pointer, assumed-shape, or assumed-rank [-Wno-redundant-contiguous]
     real, contiguous :: scalar
     call s01(a03) ! ok
     !ERROR: CONTIGUOUS pointer dummy argument may not be associated with non-CONTIGUOUS pointer actual argument
     call s01(a02)
-    !WARNING: Target of CONTIGUOUS pointer association is not known to be contiguous
+    !WARNING: Target of CONTIGUOUS pointer association is not known to be contiguous [-Wno-pointer-to-possible-noncontiguous]
     call s01(a02(:))
     !ERROR: CONTIGUOUS pointer may not be associated with a discontiguous target
     call s01(a03(::2))
diff --git a/flang/test/Semantics/call09.f90 b/flang/test/Semantics/call09.f90
index 58b2382f600ef..2adb3ac60404b 100644
--- a/flang/test/Semantics/call09.f90
+++ b/flang/test/Semantics/call09.f90
@@ -37,7 +37,7 @@ subroutine s05(p)
   end subroutine
 
   subroutine selemental1(p)
-    !PORTABILITY: A dummy procedure should not have an ELEMENTAL intrinsic as its interface
+    !PORTABILITY: A dummy procedure should not have an ELEMENTAL intrinsic as its interface [-Wno-portability]
     procedure(cos) :: p ! ok
   end subroutine
 
diff --git a/flang/test/Semantics/call10.f90 b/flang/test/Semantics/call10.f90
index 47976ca9630cd..8e16c60d89fb4 100644
--- a/flang/test/Semantics/call10.f90
+++ b/flang/test/Semantics/call10.f90
@@ -62,7 +62,7 @@ pure real function f03a(a)
     real, pointer :: a ! ok
   end function
   pure real function f04(a) ! C1583
-    !WARNING: non-POINTER dummy argument of pure function should be INTENT(IN) or VALUE
+    !WARNING: non-POINTER dummy argument of pure function should be INTENT(IN) or VALUE [-Wno-relaxed-pure-dummy]
     real, intent(out) :: a
   end function
   pure real function f04a(a)
diff --git a/flang/test/Semantics/call14.f90 b/flang/test/Semantics/call14.f90
index fba11d35790b2..2cf45d1f04217 100644
--- a/flang/test/Semantics/call14.f90
+++ b/flang/test/Semantics/call14.f90
@@ -9,7 +9,7 @@ module m
   !ERROR: VALUE attribute may apply only to a dummy data object
   subroutine C863(notData,assumedSize,coarray,coarrayComponent,assumedRank,assumedLen)
     external :: notData
-    !WARNING: Only a dummy argument should have an INTENT, VALUE, or OPTIONAL attribute
+    !WARNING: Only a dummy argument should have an INTENT, VALUE, or OPTIONAL attribute [-Wno-ignore-irrelevant-attributes]
     real, value :: notADummy
     value :: notData
     !ERROR: VALUE attribute may not apply to an assumed-size array
@@ -20,7 +20,7 @@ subroutine C863(notData,assumedSize,coarray,coarrayComponent,assumedRank,assumed
     type(hasCoarray), value :: coarrayComponent
     !ERROR: VALUE attribute may not apply to an assumed-rank array
     real, value :: assumedRank(..)
-    !PORTABILITY: VALUE attribute on assumed-length CHARACTER may not be portable
+    !PORTABILITY: VALUE attribute on assumed-length CHARACTER may not be portable [-Wno-portability]
     character(*), value :: assumedLen
   end subroutine
   subroutine C864(allocatable, inout, out, pointer, volatile)
diff --git a/flang/test/Semantics/call24.f90 b/flang/test/Semantics/call24.f90
index c1053db93648f..a782bc651ab27 100644
--- a/flang/test/Semantics/call24.f90
+++ b/flang/test/Semantics/call24.f90
@@ -38,7 +38,7 @@ subroutine test()
 
   !ERROR: References to the procedure 'bar' require an explicit interface
   !BECAUSE: a dummy procedure is optional or a pointer
-  !WARNING: If the procedure's interface were explicit, this reference would be in error
+  !WARNING: If the procedure's interface were explicit, this reference would be in error [-Wno-known-bad-implicit-interface]
   !BECAUSE: Actual argument associated with procedure pointer dummy argument 'a_pointer=' is not a procedure pointer
   call bar(sin)
 
diff --git a/flang/test/Semantics/call27.f90 b/flang/test/Semantics/call27.f90
index f401eb254fde0..9c00393993574 100644
--- a/flang/test/Semantics/call27.f90
+++ b/flang/test/Semantics/call27.f90
@@ -4,9 +4,9 @@ program test
   real, allocatable :: a
   !ERROR: NULL() actual argument 'NULL()' may not be associated with allocatable dummy argument dummy argument 'a=' that is INTENT(OUT) or INTENT(IN OUT)
   call foo0(null())
-  !WARNING: NULL() actual argument 'NULL()' should not be associated with allocatable dummy argument dummy argument 'a=' without INTENT(IN)
+  !WARNING: NULL() actual argument 'NULL()' should not be associated with allocatable dummy argument dummy argument 'a=' without INTENT(IN) [-Wno-null-actual-for-default-intent-allocatable]
   call foo1(null())
-  !PORTABILITY: Allocatable dummy argument 'a=' is associated with NULL()
+  !PORTABILITY: Allocatable dummy argument 'a=' is associated with NULL() [-Wno-null-actual-for-allocatable]
   call foo2(null())
   call foo3(null()) ! ok
   !ERROR: Actual argument associated with INTENT(IN OUT) dummy argument 'a=' is not definable
diff --git a/flang/test/Semantics/call30.f90 b/flang/test/Semantics/call30.f90
index 7aec5903606ec..2e80fbc52d68a 100644
--- a/flang/test/Semantics/call30.f90
+++ b/flang/test/Semantics/call30.f90
@@ -23,49 +23,49 @@ subroutine vol_dum_int_arr(my_int_arr)
   end subroutine vol_dum_int_arr
 
   subroutine test_all_subprograms()
-    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_int=' is not definable
+    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_int=' is not definable [-Wno-undefinable-asynchronous-or-volatile-actual]
     !BECAUSE: '6_4' is not a variable or pointer
     call vol_dum_int(6)
-    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_int=' is not definable
+    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_int=' is not definable [-Wno-undefinable-asynchronous-or-volatile-actual]
     !BECAUSE: '18_4' is not a variable or pointer
     call vol_dum_int(6+12)
-    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_int=' is not definable
+    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_int=' is not definable [-Wno-undefinable-asynchronous-or-volatile-actual]
     !BECAUSE: '72_4' is not a variable or pointer
     call vol_dum_int(6*12)
-    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_int=' is not definable
+    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_int=' is not definable [-Wno-undefinable-asynchronous-or-volatile-actual]
     !BECAUSE: '-3_4' is not a variable or pointer
     call vol_dum_int(-6/2)
-    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_real=' is not definable
+    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_real=' is not definable [-Wno-undefinable-asynchronous-or-volatile-actual]
     !BECAUSE: '3.1415927410125732421875_4' is not a variable or pointer
     call vol_dum_real(3.141592653)
-    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_real=' is not definable
+    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_real=' is not definable [-Wno-undefinable-asynchronous-or-volatile-actual]
     !BECAUSE: '3.1415927410125732421875_4' is not a variable or pointer
     call vol_dum_real(3.141592653 + (-10.6e-11))
-    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_real=' is not definable
+    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_real=' is not definable [-Wno-undefinable-asynchronous-or-volatile-actual]
     !BECAUSE: '3.3300884272335906644002534449100494384765625e-10_4' is not a variable or pointer
     call vol_dum_real(3.141592653 * 10.6e-11)
-    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_real=' is not definable
+    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_real=' is not definable [-Wno-undefinable-asynchronous-or-volatile-actual]
     !BECAUSE: '-2.9637666816e10_4' is not a variable or pointer
     call vol_dum_real(3.141592653 / (-10.6e-11))
-    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_complex=' is not definable
+    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_complex=' is not definable [-Wno-undefinable-asynchronous-or-volatile-actual]
     !BECAUSE: '(1._4,3.2000000476837158203125_4)' is not a variable or pointer
     call vol_dum_complex((1., 3.2))
-    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_complex=' is not definable
+    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_complex=' is not definable [-Wno-undefinable-asynchronous-or-volatile-actual]
     !BECAUSE: '(-1._4,6.340000152587890625_4)' is not a variable or pointer
     call vol_dum_complex((1., 3.2) + (-2., 3.14))
-    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_complex=' is not definable
+    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_complex=' is not definable [-Wno-undefinable-asynchronous-or-volatile-actual]
     !BECAUSE: '(-1.2048000335693359375e1_4,-3.2599999904632568359375_4)' is not a variable or pointer
     call vol_dum_complex((1., 3.2) * (-2., 3.14))
-    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_complex=' is not definable
+    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_complex=' is not definable [-Wno-undefinable-asynchronous-or-volatile-actual]
     !BECAUSE: '(5.80680549144744873046875e-1_4,-6.8833148479461669921875e-1_4)' is not a variable or pointer
     call vol_dum_complex((1., 3.2) / (-2., 3.14))
-    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_int_arr=' is not definable
+    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_int_arr=' is not definable [-Wno-undefinable-asynchronous-or-volatile-actual]
     !BECAUSE: '[INTEGER(4)::1_4,2_4,3_4,4_4]' is not a variable or pointer
     call vol_dum_int_arr((/ 1, 2, 3, 4 /))
-    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_int_arr=' is not definable
+    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_int_arr=' is not definable [-Wno-undefinable-asynchronous-or-volatile-actual]
     !BECAUSE: 'reshape([INTEGER(4)::1_4,2_4,3_4,4_4],shape=[2,2])' is not a variable or pointer
     call vol_dum_int_arr(reshape((/ 1, 2, 3, 4 /), (/ 2, 2/)))
-    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_int_arr=' is not definable
+    !WARNING: Actual argument associated with VOLATILE dummy argument 'my_int_arr=' is not definable [-Wno-undefinable-asynchronous-or-volatile-actual]
     !BECAUSE: '[INTEGER(4)::1_4,2_4,3_4,4_4]' is not a variable or pointer
     call vol_dum_int_arr((/ 1, 2, 3, 4 /))
   end subroutine test_all_subprograms
diff --git a/flang/test/Semantics/call31.f90 b/flang/test/Semantics/call31.f90
index d9fd2cc60ec33..377fc642809fb 100644
--- a/flang/test/Semantics/call31.f90
+++ b/flang/test/Semantics/call31.f90
@@ -4,7 +4,7 @@
       module m
        contains
         subroutine subr(parg)
-          !PORTABILITY: A dummy procedure pointer should not have assumed-length CHARACTER(*) result type
+          !PORTABILITY: A dummy procedure pointer should not have assumed-length CHARACTER(*) result type [-Wno-portability]
           procedure(character(*)), pointer :: parg
           !ERROR: An assumed (*) type parameter may be used only for a (non-statement function) dummy argument, associate name, character named constant, or external function result
           procedure(character(*)), pointer :: plocal
@@ -14,7 +14,7 @@ subroutine subr(parg)
         end subroutine
 
         subroutine subr_1(parg_1)
-          !PORTABILITY: A dummy procedure pointer should not have assumed-length CHARACTER(*) result type
+          !PORTABILITY: A dummy procedure pointer should not have assumed-length CHARACTER(*) result type [-Wno-portability]
           procedure(character(*)), pointer :: parg_1
           print *, parg_1()
         end subroutine
diff --git a/flang/test/Semantics/call33.f90 b/flang/test/Semantics/call33.f90
index 285c4be98a9db..a0105a8db0cef 100644
--- a/flang/test/Semantics/call33.f90
+++ b/flang/test/Semantics/call33.f90
@@ -29,7 +29,7 @@ program test
   character(4) long, longarr(1)
   character(4), allocatable :: longalloc
   character(4), pointer :: longptr
-  !WARNING: Actual argument variable length '2' is less than expected length '3'
+  !WARNING: Actual argument variable length '2' is less than expected length '3' [-Wno-short-character-actual]
   call s1(short)
   !ERROR: Actual argument array has fewer characters (2) than dummy argument 'x=' array (3)
   call s2(shortarr)
diff --git a/flang/test/Semantics/call34.f90 b/flang/test/Semantics/call34.f90
index 325a267309d46..b412950f7b2f2 100644
--- a/flang/test/Semantics/call34.f90
+++ b/flang/test/Semantics/call34.f90
@@ -11,11 +11,11 @@ program test
   real, target :: a(1)
   real :: b(1)
   call foo(a) ! ok
-  !WARNING: Any pointer associated with TARGET dummy argument 'a=' during this call must not be used afterwards, as 'b' is not a target
+  !WARNING: Any pointer associated with TARGET dummy argument 'a=' during this call must not be used afterwards, as 'b' is not a target [-Wno-non-target-passed-to-target]
   call foo(b)
-  !WARNING: Any pointer associated with TARGET dummy argument 'a=' during this call will not be associated with the value of '(a)' afterwards
+  !WARNING: Any pointer associated with TARGET dummy argument 'a=' during this call will not be associated with the value of '(a)' afterwards [-Wno-non-target-passed-to-target]
   call foo((a))
-  !WARNING: Any pointer associated with TARGET dummy argument 'a=' during this call will not be associated with the value of 'a([INTEGER(8)::1_8])' afterwards
+  !WARNING: Any pointer associated with TARGET dummy argument 'a=' during this call will not be associated with the value of 'a([INTEGER(8)::1_8])' afterwards [-Wno-non-target-passed-to-target]
   call foo(a([1]))
   !ERROR: Scalar actual argument may not be associated with assumed-shape dummy argument 'a='
   call foo(a(1))
diff --git a/flang/test/Semantics/call35.f90 b/flang/test/Semantics/call35.f90
index ff819481226d6..dd96b1e0ccdf4 100644
--- a/flang/test/Semantics/call35.f90
+++ b/flang/test/Semantics/call35.f90
@@ -5,14 +5,14 @@ subroutine s1
 end
 
 subroutine s2
-  !WARNING: Reference to the procedure 'ext' has an implicit interface that is distinct from another reference: distinct numbers of dummy arguments
+  !WARNING: Reference to the procedure 'ext' has an implicit interface that is distinct from another reference: distinct numbers of dummy arguments [-Wno-incompatible-implicit-interfaces]
   call ext(1.)
   call myerror('abcd') ! don't warn about distinct lengths
 end
 
 subroutine s3
   interface
-    !WARNING: The global subprogram 'ext' is not compatible with its local procedure declaration (incompatible procedure attributes: ImplicitInterface)
+    !WARNING: The global subprogram 'ext' is not compatible with its local procedure declaration (incompatible procedure attributes: ImplicitInterface) [-Wno-external-interface-mismatch]
     subroutine ext(n)
       integer n
     end
diff --git a/flang/test/Semantics/call36.f90 b/flang/test/Semantics/call36.f90
index 779aafdd2340a..14ef539197acc 100644
--- a/flang/test/Semantics/call36.f90
+++ b/flang/test/Semantics/call36.f90
@@ -15,7 +15,7 @@ subroutine test
     call intentInUnlimited(scalar)
     !ERROR: Actual argument associated with POINTER dummy argument 'x=' must also be POINTER unless INTENT(IN)
     call intentInOutUnlimited(scalar)
-    !PORTABILITY: If a POINTER or ALLOCATABLE dummy or actual argument is unlimited polymorphic, both should be so
+    !PORTABILITY: If a POINTER or ALLOCATABLE dummy or actual argument is unlimited polymorphic, both should be so [-Wno-relaxed-intent-in-checking]
     call intentInUnlimited(arrayptr)
     !ERROR: If a POINTER or ALLOCATABLE dummy or actual argument is unlimited polymorphic, both must be so
     call intentInOutUnlimited(arrayptr)
diff --git a/flang/test/Semantics/call37.f90 b/flang/test/Semantics/call37.f90
index 6018b8697ad5f..55a9ab96ec5f6 100644
--- a/flang/test/Semantics/call37.f90
+++ b/flang/test/Semantics/call37.f90
@@ -28,15 +28,15 @@ subroutine exprLen(s)
 
 module m1
   interface
-    !WARNING: The global subprogram 'constlen' is not compatible with its local procedure declaration (incompatible dummy argument #1: incompatible dummy data object types: CHARACTER(KIND=1,LEN=1_8) vs CHARACTER(KIND=1,LEN=2_8))
+    !WARNING: The global subprogram 'constlen' is not compatible with its local procedure declaration (incompatible dummy argument #1: incompatible dummy data object types: CHARACTER(KIND=1,LEN=1_8) vs CHARACTER(KIND=1,LEN=2_8)) [-Wno-external-interface-mismatch]
     subroutine constLen(s)
       character(len=2) s
     end
-    !WARNING: The global subprogram 'assumedlen' is not compatible with its local procedure declaration (incompatible dummy argument #1: assumed-length character vs explicit-length character)
+    !WARNING: The global subprogram 'assumedlen' is not compatible with its local procedure declaration (incompatible dummy argument #1: assumed-length character vs explicit-length character) [-Wno-external-interface-mismatch]
     subroutine assumedLen(s)
       character(len=2) s
     end
-    !WARNING: The global subprogram 'exprlen' is not compatible with its local procedure declaration (incompatible dummy argument #1: constant-length vs non-constant-length character dummy arguments)
+    !WARNING: The global subprogram 'exprlen' is not compatible with its local procedure declaration (incompatible dummy argument #1: constant-length vs non-constant-length character dummy arguments) [-Wno-external-interface-mismatch]
     subroutine exprLen(s)
       character(len=2) s
     end
@@ -45,11 +45,11 @@ subroutine exprLen(s)
 
 module m2
   interface
-    !WARNING: The global subprogram 'constlen' is not compatible with its local procedure declaration (incompatible dummy argument #1: assumed-length character vs explicit-length character)
+    !WARNING: The global subprogram 'constlen' is not compatible with its local procedure declaration (incompatible dummy argument #1: assumed-length character vs explicit-length character) [-Wno-external-interface-mismatch]
     subroutine constLen(s)
       character(len=*) s
     end
-    !WARNING: The global subprogram 'exprlen' is not compatible with its local procedure declaration (incompatible dummy argument #1: assumed-length character vs explicit-length character)
+    !WARNING: The global subprogram 'exprlen' is not compatible with its local procedure declaration (incompatible dummy argument #1: assumed-length character vs explicit-length character) [-Wno-external-interface-mismatch]
     subroutine exprLen(s)
       character(len=*) s
     end
@@ -58,12 +58,12 @@ subroutine exprLen(s)
 
 module m3
   interface
-    !WARNING: The global subprogram 'constlen' is not compatible with its local procedure declaration (incompatible dummy argument #1: constant-length vs non-constant-length character dummy arguments)
+    !WARNING: The global subprogram 'constlen' is not compatible with its local procedure declaration (incompatible dummy argument #1: constant-length vs non-constant-length character dummy arguments) [-Wno-external-interface-mismatch]
     subroutine constLen(s)
       common n
       character(len=n) s
     end
-    !WARNING: The global subprogram 'assumedlen' is not compatible with its local procedure declaration (incompatible dummy argument #1: assumed-length character vs explicit-length character)
+    !WARNING: The global subprogram 'assumedlen' is not compatible with its local procedure declaration (incompatible dummy argument #1: assumed-length character vs explicit-length character) [-Wno-external-interface-mismatch]
     subroutine assumedLen(s)
       common n
       character(len=n) s
diff --git a/flang/test/Semantics/call38.f90 b/flang/test/Semantics/call38.f90
index b1a35973e35fe..7ca20d04ec48e 100644
--- a/flang/test/Semantics/call38.f90
+++ b/flang/test/Semantics/call38.f90
@@ -516,9 +516,9 @@ subroutine test
     !ERROR: Actual argument associated with coarray dummy argument 'a=' must be a coarray
     call coarray0(matrix11(1,1))
 
-    !WARNING: Actual argument variable length '1' is less than expected length '2'
+    !WARNING: Actual argument variable length '1' is less than expected length '2' [-Wno-short-character-actual]
     call scalar(scalar0(1:1))
-    !WARNING: Actual argument expression length '1' is less than expected length '2'
+    !WARNING: Actual argument expression length '1' is less than expected length '2' [-Wno-short-character-actual]
     call scalar('a')
   end
 end
diff --git a/flang/test/Semantics/call41.f90 b/flang/test/Semantics/call41.f90
index a4c7514d99ba5..4fed61b982c21 100644
--- a/flang/test/Semantics/call41.f90
+++ b/flang/test/Semantics/call41.f90
@@ -5,7 +5,7 @@ subroutine unlimited(x)
     class(*), intent(in) :: x
   end
   subroutine test
-    !PORTABILITY: passing Hollerith to unlimited polymorphic as if it were CHARACTER
+    !PORTABILITY: passing Hollerith to unlimited polymorphic as if it were CHARACTER [-Wno-hollerith-polymorphic]
     call unlimited(6HHERMAN)
     call unlimited('abc') ! ok
   end
diff --git a/flang/test/Semantics/call42.f90 b/flang/test/Semantics/call42.f90
index 2d5303b58cb01..b8312dec3ab4c 100644
--- a/flang/test/Semantics/call42.f90
+++ b/flang/test/Semantics/call42.f90
@@ -22,17 +22,17 @@ recursive subroutine typeOutAssumedRank(a,b,c,d)
     type(hasAlloc), intent(out) :: b(..)
     type(hasInit), intent(out) :: c(..)
     type(hasFinal), intent(out) :: d(..)
-    !PORTABILITY: Assumed-rank actual argument should not be associated with INTENT(OUT) assumed-rank dummy argument
+    !PORTABILITY: Assumed-rank actual argument should not be associated with INTENT(OUT) assumed-rank dummy argument [-Wno-portability]
     !ERROR: Assumed-rank actual argument may not be associated with INTENT(OUT) assumed-rank dummy argument requiring finalization, destruction, or initialization
     !ERROR: Assumed-rank actual argument may not be associated with INTENT(OUT) assumed-rank dummy argument requiring finalization, destruction, or initialization
     !ERROR: Assumed-rank actual argument may not be associated with INTENT(OUT) assumed-rank dummy argument requiring finalization, destruction, or initialization
     call typeOutAssumedRank(a, b, c, d)
-    !PORTABILITY: Assumed-rank actual argument should not be associated with INTENT(OUT) assumed-rank dummy argument
+    !PORTABILITY: Assumed-rank actual argument should not be associated with INTENT(OUT) assumed-rank dummy argument [-Wno-portability]
     !ERROR: Assumed-rank actual argument may not be associated with INTENT(OUT) assumed-rank dummy argument requiring finalization, destruction, or initialization
     !ERROR: Assumed-rank actual argument may not be associated with INTENT(OUT) assumed-rank dummy argument requiring finalization, destruction, or initialization
     !ERROR: Assumed-rank actual argument may not be associated with INTENT(OUT) assumed-rank dummy argument requiring finalization, destruction, or initialization
     call classOutAssumedRank(a, b, c, d)
-    !PORTABILITY: Assumed-rank actual argument should not be associated with INTENT(OUT) assumed-rank dummy argument
+    !PORTABILITY: Assumed-rank actual argument should not be associated with INTENT(OUT) assumed-rank dummy argument [-Wno-portability]
     !ERROR: Assumed-rank actual argument may not be associated with INTENT(OUT) assumed-rank dummy argument requiring finalization, destruction, or initialization
     !ERROR: Assumed-rank actual argument may not be associated with INTENT(OUT) assumed-rank dummy argument requiring finalization, destruction, or initialization
     !ERROR: Assumed-rank actual argument may not be associated with INTENT(OUT) assumed-rank dummy argument requiring finalization, destruction, or initialization
@@ -95,17 +95,17 @@ subroutine typeAssumedSize(a,b,c,d)
     type(hasAlloc) b(*)
     type(hasInit) c(*)
     type(hasFinal) d(*)
-    !PORTABILITY: Assumed-size actual argument should not be associated with INTENT(OUT) assumed-rank dummy argument
+    !PORTABILITY: Assumed-size actual argument should not be associated with INTENT(OUT) assumed-rank dummy argument [-Wno-portability]
     !ERROR: Assumed-size actual argument may not be associated with INTENT(OUT) assumed-rank dummy argument requiring finalization, destruction, or initialization
     !ERROR: Assumed-size actual argument may not be associated with INTENT(OUT) assumed-rank dummy argument requiring finalization, destruction, or initialization
     !ERROR: Assumed-size actual argument may not be associated with INTENT(OUT) assumed-rank dummy argument requiring finalization, destruction, or initialization
     call typeOutAssumedRank(a,b,c,d)
-    !PORTABILITY: Assumed-size actual argument should not be associated with INTENT(OUT) assumed-rank dummy argument
+    !PORTABILITY: Assumed-size actual argument should not be associated with INTENT(OUT) assumed-rank dummy argument [-Wno-portability]
     !ERROR: Assumed-size actual argument may not be associated with INTENT(OUT) assumed-rank dummy argument requiring finalization, destruction, or initialization
     !ERROR: Assumed-size actual argument may not be associated with INTENT(OUT) assumed-rank dummy argument requiring finalization, destruction, or initialization
     !ERROR: Assumed-size actual argument may not be associated with INTENT(OUT) assumed-rank dummy argument requiring finalization, destruction, or initialization
     call classOutAssumedRank(a,b,c,d)
-    !PORTABILITY: Assumed-size actual argument should not be associated with INTENT(OUT) assumed-rank dummy argument
+    !PORTABILITY: Assumed-size actual argument should not be associated with INTENT(OUT) assumed-rank dummy argument [-Wno-portability]
     !ERROR: Assumed-size actual argument may not be associated with INTENT(OUT) assumed-rank dummy argument requiring finalization, destruction, or initialization
     !ERROR: Assumed-size actual argument may not be associated with INTENT(OUT) assumed-rank dummy argument requiring finalization, destruction, or initialization
     !ERROR: Assumed-size actual argument may not be associated with INTENT(OUT) assumed-rank dummy argument requiring finalization, destruction, or initialization
diff --git a/flang/test/Semantics/call43.f90 b/flang/test/Semantics/call43.f90
index d8cc543a4838a..280e315f3f747 100644
--- a/flang/test/Semantics/call43.f90
+++ b/flang/test/Semantics/call43.f90
@@ -5,11 +5,11 @@ subroutine from(a, b, c, d)
   call to(a)
   call to(a(1)) ! ok
   call to(b) ! ok, passed via temp
-  !WARNING: Reference to the procedure 'to' has an implicit interface that is distinct from another reference: incompatible dummy argument #1: incompatible dummy data object shapes
+  !WARNING: Reference to the procedure 'to' has an implicit interface that is distinct from another reference: incompatible dummy argument #1: incompatible dummy data object shapes [-Wno-incompatible-implicit-interfaces]
   call to(b(1))
-  !WARNING: Reference to the procedure 'to' has an implicit interface that is distinct from another reference: incompatible dummy argument #1: incompatible dummy data object shapes
+  !WARNING: Reference to the procedure 'to' has an implicit interface that is distinct from another reference: incompatible dummy argument #1: incompatible dummy data object shapes [-Wno-incompatible-implicit-interfaces]
   call to(c)
-  !WARNING: Reference to the procedure 'to' has an implicit interface that is distinct from another reference: incompatible dummy argument #1: incompatible dummy data object shapes
+  !WARNING: Reference to the procedure 'to' has an implicit interface that is distinct from another reference: incompatible dummy argument #1: incompatible dummy data object shapes [-Wno-incompatible-implicit-interfaces]
   call to(1.)
   call to([1., 2.]) ! ok
   call to(d) ! ok
diff --git a/flang/test/Semantics/call44.f90 b/flang/test/Semantics/call44.f90
index f7c4c9093b432..c970a0112ba04 100644
--- a/flang/test/Semantics/call44.f90
+++ b/flang/test/Semantics/call44.f90
@@ -2,10 +2,10 @@
 subroutine assumedshape(normal, contig)
   real normal(:)
   real, contiguous :: contig(:)
-  !WARNING: If the procedure's interface were explicit, this reference would be in error
+  !WARNING: If the procedure's interface were explicit, this reference would be in error [-Wno-known-bad-implicit-interface]
   !BECAUSE: Element of assumed-shape array may not be associated with a dummy argument 'assumedsize=' array
   call seqAssociate(normal(1))
-  !PORTABILITY: Element of contiguous assumed-shape array is accepted for storage sequence association
+  !PORTABILITY: Element of contiguous assumed-shape array is accepted for storage sequence association [-Wno-contiguous-ok-for-seq-association]
   call seqAssociate(contig(1))
 end
 subroutine seqAssociate(assumedSize)
diff --git a/flang/test/Semantics/case01.f90 b/flang/test/Semantics/case01.f90
index 15bc30498ab51..c899570fa3656 100644
--- a/flang/test/Semantics/case01.f90
+++ b/flang/test/Semantics/case01.f90
@@ -129,7 +129,7 @@ program selectCaseProg
   end select
 
   select case (grade2)
-     !WARNING: CASE has lower bound greater than upper bound
+     !WARNING: CASE has lower bound greater than upper bound [-Wno-empty-case]
      case (51:50)
      case (100:)
      case (:30)
@@ -183,13 +183,13 @@ subroutine test_overflow
   integer :: j
   select case(1_1)
   case (127)
-  !WARNING: CASE value (128_4) overflows type (INTEGER(1)) of SELECT CASE expression
+  !WARNING: CASE value (128_4) overflows type (INTEGER(1)) of SELECT CASE expression [-Wno-case-overflow]
   case (128)
-  !WARNING: CASE value (129_4) overflows type (INTEGER(1)) of SELECT CASE expression
-  !WARNING: CASE value (130_4) overflows type (INTEGER(1)) of SELECT CASE expression
+  !WARNING: CASE value (129_4) overflows type (INTEGER(1)) of SELECT CASE expression [-Wno-case-overflow]
+  !WARNING: CASE value (130_4) overflows type (INTEGER(1)) of SELECT CASE expression [-Wno-case-overflow]
   case (129:130)
-  !WARNING: CASE value (-130_4) overflows type (INTEGER(1)) of SELECT CASE expression
-  !WARNING: CASE value (-129_4) overflows type (INTEGER(1)) of SELECT CASE expression
+  !WARNING: CASE value (-130_4) overflows type (INTEGER(1)) of SELECT CASE expression [-Wno-case-overflow]
+  !WARNING: CASE value (-129_4) overflows type (INTEGER(1)) of SELECT CASE expression [-Wno-case-overflow]
   case (-130:-129)
   case (-128)
   !ERROR: Must be a scalar value, but is a rank-1 array
diff --git a/flang/test/Semantics/common-blocks.f90 b/flang/test/Semantics/common-blocks.f90
index 65f17f6d3fe97..77531bac1b32d 100644
--- a/flang/test/Semantics/common-blocks.f90
+++ b/flang/test/Semantics/common-blocks.f90
@@ -7,7 +7,7 @@ subroutine init_1
   common x, y
   common /a/ xa, ya
   common /b/ xb, yb
-  !WARNING: Blank COMMON object 'x' in a DATA statement is not standard
+  !WARNING: Blank COMMON object 'x' in a DATA statement is not standard [-Wno-data-stmt-extensions]
   data x /42./, xa /42./, yb/42./
 end subroutine
 
@@ -18,7 +18,7 @@ subroutine init_conflict
   common /a/ xa, ya
   common /b/ xb, yb
   equivalence (yb, yb_eq)
-  !WARNING: Blank COMMON object 'x' in a DATA statement is not standard
+  !WARNING: Blank COMMON object 'x' in a DATA statement is not standard [-Wno-data-stmt-extensions]
   !ERROR: Multiple initialization of COMMON block /b/
   data x /66./, xa /66./, yb_eq /66./
 end subroutine
diff --git a/flang/test/Semantics/contiguous01.f90 b/flang/test/Semantics/contiguous01.f90
index 89382775261b8..1ef3b07151978 100644
--- a/flang/test/Semantics/contiguous01.f90
+++ b/flang/test/Semantics/contiguous01.f90
@@ -5,30 +5,30 @@ module m0
 end
 module m
   use m0
-  !WARNING: Use-associated 'p1' already has 'CONTIGUOUS' attribute
+  !WARNING: Use-associated 'p1' already has 'CONTIGUOUS' attribute [-Wno-redundant-attribute]
   contiguous p1
   !ERROR: Cannot change CONTIGUOUS attribute on use-associated 'p2'
   contiguous p2
-  !PORTABILITY: CONTIGUOUS entity 'x' should be an array pointer, assumed-shape, or assumed-rank
+  !PORTABILITY: CONTIGUOUS entity 'x' should be an array pointer, assumed-shape, or assumed-rank [-Wno-redundant-contiguous]
   real, contiguous :: x
-  !PORTABILITY: CONTIGUOUS entity 'scalar' should be an array pointer, assumed-shape, or assumed-rank
+  !PORTABILITY: CONTIGUOUS entity 'scalar' should be an array pointer, assumed-shape, or assumed-rank [-Wno-redundant-contiguous]
   real, contiguous, pointer :: scalar
-  !PORTABILITY: CONTIGUOUS entity 'allocatable' should be an array pointer, assumed-shape, or assumed-rank
+  !PORTABILITY: CONTIGUOUS entity 'allocatable' should be an array pointer, assumed-shape, or assumed-rank [-Wno-redundant-contiguous]
   real, contiguous, allocatable :: allocatable
  contains
-  !PORTABILITY: CONTIGUOUS entity 'func' should be an array pointer, assumed-shape, or assumed-rank
+  !PORTABILITY: CONTIGUOUS entity 'func' should be an array pointer, assumed-shape, or assumed-rank [-Wno-redundant-contiguous]
   function func(ashape,arank) result(r)
     real, contiguous :: ashape(:) ! ok
     real, contiguous :: arank(..) ! ok
-    !PORTABILITY: CONTIGUOUS entity 'r' should be an array pointer, assumed-shape, or assumed-rank
+    !PORTABILITY: CONTIGUOUS entity 'r' should be an array pointer, assumed-shape, or assumed-rank [-Wno-redundant-contiguous]
     real :: r(10)
-    !PORTABILITY: CONTIGUOUS entity 'r2' should be an array pointer, assumed-shape, or assumed-rank
+    !PORTABILITY: CONTIGUOUS entity 'r2' should be an array pointer, assumed-shape, or assumed-rank [-Wno-redundant-contiguous]
     real :: r2(10)
     contiguous func
     contiguous r
     contiguous e
     contiguous r2
-    !PORTABILITY: CONTIGUOUS entity 'e' should be an array pointer, assumed-shape, or assumed-rank
+    !PORTABILITY: CONTIGUOUS entity 'e' should be an array pointer, assumed-shape, or assumed-rank [-Wno-redundant-contiguous]
     entry e() result(r2)
     r2 = 0
   end
diff --git a/flang/test/Semantics/cuf01.cuf b/flang/test/Semantics/cuf01.cuf
index 574d345eae045..907a294e5d5ab 100644
--- a/flang/test/Semantics/cuf01.cuf
+++ b/flang/test/Semantics/cuf01.cuf
@@ -2,15 +2,15 @@
 ! Test conflicting CUDA subprogram attributes
 module m1
  contains
-  !WARNING: ATTRIBUTES(Host) appears more than once
+  !WARNING: ATTRIBUTES(Host) appears more than once [-Wno-redundant-attribute]
   attributes(host,host) subroutine ok1; end
-  !WARNING: ATTRIBUTES(Host) appears more than once
+  !WARNING: ATTRIBUTES(Host) appears more than once [-Wno-redundant-attribute]
   attributes(host) attributes(host) subroutine ok2; end
   attributes(host,device) subroutine ok3; end
   attributes(device,host) subroutine ok4; end
-  !WARNING: ATTRIBUTES(Host) appears more than once
+  !WARNING: ATTRIBUTES(Host) appears more than once [-Wno-redundant-attribute]
   attributes(host,device,host) subroutine ok5; end
-  !WARNING: ATTRIBUTES(Device) appears more than once
+  !WARNING: ATTRIBUTES(Device) appears more than once [-Wno-redundant-attribute]
   attributes(device,host,device) subroutine ok6; end
   !ERROR: ATTRIBUTES(Global) conflicts with earlier ATTRIBUTES(Host)
   attributes(host,global) subroutine conflict1; end
diff --git a/flang/test/Semantics/cuf03.cuf b/flang/test/Semantics/cuf03.cuf
index fe9dd5b3ecf05..ec8844831c3ca 100644
--- a/flang/test/Semantics/cuf03.cuf
+++ b/flang/test/Semantics/cuf03.cuf
@@ -38,14 +38,14 @@ module m
   !ERROR: Object 'mmp' with ATTRIBUTES(MANAGED) must also be allocatable, automatic, explicit shape, or a dummy argument
   real, managed, pointer :: mmp(:)
   real, managed, target :: mmt
-  !WARNING: Object 'mp' with ATTRIBUTES(PINNED) should also be allocatable
+  !WARNING: Object 'mp' with ATTRIBUTES(PINNED) should also be allocatable [-Wno-cuda-usage]
   real, pinned :: mp
-  !WARNING: Object 'mpi' with ATTRIBUTES(PINNED) should also be allocatable
+  !WARNING: Object 'mpi' with ATTRIBUTES(PINNED) should also be allocatable [-Wno-cuda-usage]
   real, pinned :: mpi = 1.
   real, pinned, allocatable :: mpl ! ok
-  !ERROR: Object 'mpp' with ATTRIBUTES(PINNED) may not be a pointer
+  !ERROR: Object 'mpp' with ATTRIBUTES(PINNED) may not be a pointer [-Wno-cuda-usage]
   real, pinned, pointer :: mpp
-  !WARNING: Object 'mpt' with ATTRIBUTES(PINNED) should also be allocatable
+  !WARNING: Object 'mpt' with ATTRIBUTES(PINNED) should also be allocatable [-Wno-cuda-usage]
   real, pinned, target :: mpt ! ok
   !ERROR: ATTRIBUTES(TEXTURE) is obsolete and no longer supported
   real, texture, pointer :: mt
@@ -67,7 +67,7 @@ module m
     integer, intent(in) :: n
     real, device :: da(*) ! ok
     real, managed :: ma(n) ! ok
-    !WARNING: Pointer 'dp' may not be associated in a device subprogram
+    !WARNING: Pointer 'dp' may not be associated in a device subprogram [-Wno-cuda-usage]
     real, device, pointer :: dp
     real, constant :: rc ! ok
     real, shared :: rs ! ok
diff --git a/flang/test/Semantics/cuf04.cuf b/flang/test/Semantics/cuf04.cuf
index 2e2faa90b490d..279ebdd13bea5 100644
--- a/flang/test/Semantics/cuf04.cuf
+++ b/flang/test/Semantics/cuf04.cuf
@@ -4,9 +4,9 @@ module m
  contains
   attributes(device) subroutine devsubr(n)
     integer, intent(in) :: n
-    !WARNING: 'x1' should not have the SAVE attribute or initialization in a device subprogram
+    !WARNING: 'x1' should not have the SAVE attribute or initialization in a device subprogram [-Wno-cuda-usage]
     real, save :: x1
-    !WARNING: 'x2' should not have the SAVE attribute or initialization in a device subprogram
+    !WARNING: 'x2' should not have the SAVE attribute or initialization in a device subprogram [-Wno-cuda-usage]
     real :: x2 = 1.
     !ERROR: Device subprogram 'devsubr' cannot call itself
     if (n > 0) call devsubr(n-1)
diff --git a/flang/test/Semantics/cuf09.cuf b/flang/test/Semantics/cuf09.cuf
index 1e23819f9afe8..94208b05ef0d8 100644
--- a/flang/test/Semantics/cuf09.cuf
+++ b/flang/test/Semantics/cuf09.cuf
@@ -15,7 +15,7 @@ module m
     print*,'from device'
     print '(f10.5)', (x(ivar), ivar = 1, 10)
     write(*,*), "Hello world from device!"
-    !WARNING: I/O statement might not be supported on device
+    !WARNING: I/O statement might not be supported on device [-Wno-cuda-usage]
     write(12,'(10F4.1)'), x
   end
   attributes(global) subroutine devsub3(n)
diff --git a/flang/test/Semantics/data06.f90 b/flang/test/Semantics/data06.f90
index 08b4700028438..99ac4c2714188 100644
--- a/flang/test/Semantics/data06.f90
+++ b/flang/test/Semantics/data06.f90
@@ -41,7 +41,7 @@ real function rfunc(x)
   data rp/rfunc/
   procedure(rfunc), pointer :: rpp
   real, target :: rt
-  !WARNING: Procedure pointer 'rpp' in a DATA statement is not standard
+  !WARNING: Procedure pointer 'rpp' in a DATA statement is not standard [-Wno-data-stmt-extensions]
   !ERROR: Data object 'rt' may not be used to initialize 'rpp', which is a procedure pointer
   data rpp/rt/
   !ERROR: Initializer for 'rt' must not be a pointer
@@ -49,7 +49,7 @@ real function rfunc(x)
   !ERROR: Initializer for 'rt' must not be a procedure
   data rt/rfunc/
   integer :: jx, jy
-  !WARNING: DATA statement value initializes 'jx' of type 'INTEGER(4)' with CHARACTER
+  !WARNING: DATA statement value initializes 'jx' of type 'INTEGER(4)' with CHARACTER [-Wno-data-stmt-extensions]
   data jx/'abc'/
   !ERROR: DATA statement value could not be converted to the type 'INTEGER(4)' of the object 'jx'
   data jx/t1()/
diff --git a/flang/test/Semantics/data17.f90 b/flang/test/Semantics/data17.f90
index 86f1c4c6c1269..1a7ca14bb09b2 100644
--- a/flang/test/Semantics/data17.f90
+++ b/flang/test/Semantics/data17.f90
@@ -1,8 +1,8 @@
 ! RUN: %python %S/test_errors.py %s %flang_fc1
 character(4) a, b, c, d, e, f
-!WARNING: DATA statement value '"abcde"' for 'a' has the wrong length
+!WARNING: DATA statement value '"abcde"' for 'a' has the wrong length [-Wno-data-length]
 data a(1:4)/'abcde'/
-!WARNING: DATA statement value '"abc"' for 'b' has the wrong length
+!WARNING: DATA statement value '"abc"' for 'b' has the wrong length [-Wno-data-length]
 data b(1:4)/'abc'/
 data c/'abcde'/ ! not a substring, conforms
 data d/'abc'/ ! not a substring, conforms
diff --git a/flang/test/Semantics/declarations04.f90 b/flang/test/Semantics/declarations04.f90
index f0ca568e7a97c..0e843819ae2f3 100644
--- a/flang/test/Semantics/declarations04.f90
+++ b/flang/test/Semantics/declarations04.f90
@@ -20,7 +20,7 @@ subroutine bar() bind(c,name="ext3")
 end
 
 block data ext3
-  !PORTABILITY: Global name 'ext4' conflicts with a module
+  !PORTABILITY: Global name 'ext4' conflicts with a module [-Wno-benign-name-clash]
   common /ext4/ x
 end
 
diff --git a/flang/test/Semantics/declarations05.f90 b/flang/test/Semantics/declarations05.f90
index b1e3d3c773160..c11499ebe00a7 100644
--- a/flang/test/Semantics/declarations05.f90
+++ b/flang/test/Semantics/declarations05.f90
@@ -27,7 +27,7 @@ pure subroutine test
     !ERROR: 'x1' may not be a local variable in a pure subprogram
     !BECAUSE: 'x1' has an impure FINAL procedure 'final'
     type(t1) x1
-    !WARNING: 'x1a' of derived type 't1' does not have a FINAL subroutine for its rank (1)
+    !WARNING: 'x1a' of derived type 't1' does not have a FINAL subroutine for its rank (1) [-Wno-final]
     type(t1), allocatable :: x1a(:)
     type(t1), parameter :: namedConst = t1() ! ok
     !ERROR: 'x2' may not be a local variable in a pure subprogram
diff --git a/flang/test/Semantics/declarations07.f90 b/flang/test/Semantics/declarations07.f90
index 8c95c163b043b..1fc7122cd4cd6 100644
--- a/flang/test/Semantics/declarations07.f90
+++ b/flang/test/Semantics/declarations07.f90
@@ -11,8 +11,8 @@ pure integer function mykind(x)
   real a, b
   integer, parameter :: ak = kind(a)
   integer, parameter :: br = rank(b)
-  !WARNING: 'a' appeared earlier as a scalar actual argument to a specification function
+  !WARNING: 'a' appeared earlier as a scalar actual argument to a specification function [-Wno-previous-scalar-use]
   dimension a(1)
-  !WARNING: 'b' appeared earlier as a scalar actual argument to a specification function
+  !WARNING: 'b' appeared earlier as a scalar actual argument to a specification function [-Wno-previous-scalar-use]
   dimension b(1)
 end
diff --git a/flang/test/Semantics/deferred01.f90 b/flang/test/Semantics/deferred01.f90
index ce406a72b8fab..21078058f7f2c 100644
--- a/flang/test/Semantics/deferred01.f90
+++ b/flang/test/Semantics/deferred01.f90
@@ -19,7 +19,7 @@ module m2
   use m1
   type, extends(absBase) :: ext
    contains
-    !WARNING: Override of PRIVATE DEFERRED 'deferredtbp' should appear in its module
+    !WARNING: Override of PRIVATE DEFERRED 'deferredtbp' should appear in its module [-Wno-inaccessible-deferred-override]
     procedure :: deferredTbp => implTbp
   end type
  contains
diff --git a/flang/test/Semantics/definable02.f90 b/flang/test/Semantics/definable02.f90
index 666fee91a97de..83280e68c7aaf 100644
--- a/flang/test/Semantics/definable02.f90
+++ b/flang/test/Semantics/definable02.f90
@@ -36,9 +36,9 @@ program test
   x1(:) = [t1()] ! ok
   x2(:) = [t2()] ! ok
   x3(:) = [t3()] ! ok
-  !PORTABILITY: Variable 'x1([INTEGER(8)::1_8])' has a vector subscript and will be finalized by non-elemental subroutine 'f1'
+  !PORTABILITY: Variable 'x1([INTEGER(8)::1_8])' has a vector subscript and will be finalized by non-elemental subroutine 'f1' [-Wno-vector-subscript-finalization]
   x1([1]) = [t1()]
-  !PORTABILITY: Variable 'x2([INTEGER(8)::1_8])' has a vector subscript and will be finalized by non-elemental subroutine 'f2'
+  !PORTABILITY: Variable 'x2([INTEGER(8)::1_8])' has a vector subscript and will be finalized by non-elemental subroutine 'f2' [-Wno-vector-subscript-finalization]
   x2([1]) = [t2()]
   x3([1]) = [t3()] ! ok
 end
diff --git a/flang/test/Semantics/dim01.f90 b/flang/test/Semantics/dim01.f90
index aba9a15b95a41..6d60714044935 100644
--- a/flang/test/Semantics/dim01.f90
+++ b/flang/test/Semantics/dim01.f90
@@ -16,21 +16,21 @@ function f0b(a)
   function f1(a,d)
     real, intent(in) :: a(:)
     integer, optional, intent(in) :: d
-    !PORTABILITY: The actual argument for DIM= is optional, pointer, or allocatable, and it is assumed to be present and equal to 1 at execution time
+    !PORTABILITY: The actual argument for DIM= is optional, pointer, or allocatable, and it is assumed to be present and equal to 1 at execution time [-Wno-optional-must-be-present]
     f1 = sum(a,dim=d)
-    !PORTABILITY: The actual argument for DIM= is optional, pointer, or allocatable, and it is assumed to be present and equal to 1 at execution time
+    !PORTABILITY: The actual argument for DIM= is optional, pointer, or allocatable, and it is assumed to be present and equal to 1 at execution time [-Wno-optional-must-be-present]
     f1 = norm2(a,dim=d)
   end function
   function f2(a,d)
     real, intent(in) :: a(:)
     integer, pointer, intent(in) :: d
-    !PORTABILITY: The actual argument for DIM= is optional, pointer, or allocatable, and it is assumed to be present and equal to 1 at execution time
+    !PORTABILITY: The actual argument for DIM= is optional, pointer, or allocatable, and it is assumed to be present and equal to 1 at execution time [-Wno-optional-must-be-present]
     f2 = sum(a,dim=d)
   end function
   function f3(a,d)
     real, intent(in) :: a(:)
     integer, allocatable, intent(in) :: d
-    !PORTABILITY: The actual argument for DIM= is optional, pointer, or allocatable, and it is assumed to be present and equal to 1 at execution time
+    !PORTABILITY: The actual argument for DIM= is optional, pointer, or allocatable, and it is assumed to be present and equal to 1 at execution time [-Wno-optional-must-be-present]
     f3 = sum(a,dim=d)
   end function
   function f10a(a)
@@ -49,23 +49,23 @@ function f11(a,d)
     real, intent(in) :: a(:,:)
     integer, optional, intent(in) :: d
     real, allocatable :: f11(:)
-    !WARNING: The actual argument for DIM= is optional, pointer, or allocatable, and may not be absent during execution; parenthesize to silence this warning
+    !WARNING: The actual argument for DIM= is optional, pointer, or allocatable, and may not be absent during execution; parenthesize to silence this warning [-Wno-optional-must-be-present]
     f11 = sum(a,dim=d)
-    !WARNING: The actual argument for DIM= is optional, pointer, or allocatable, and may not be absent during execution; parenthesize to silence this warning
+    !WARNING: The actual argument for DIM= is optional, pointer, or allocatable, and may not be absent during execution; parenthesize to silence this warning [-Wno-optional-must-be-present]
     f11 = norm2(a,dim=d)
   end function
   function f12(a,d)
     real, intent(in) :: a(:,:)
     integer, pointer, intent(in) :: d
     real, allocatable :: f12(:)
-    !WARNING: The actual argument for DIM= is optional, pointer, or allocatable, and may not be absent during execution; parenthesize to silence this warning
+    !WARNING: The actual argument for DIM= is optional, pointer, or allocatable, and may not be absent during execution; parenthesize to silence this warning [-Wno-optional-must-be-present]
     f12 = sum(a,dim=d)
   end function
   function f13(a,d)
     real, intent(in) :: a(:,:)
     integer, allocatable, intent(in) :: d
     real, allocatable :: f13(:)
-    !WARNING: The actual argument for DIM= is optional, pointer, or allocatable, and may not be absent during execution; parenthesize to silence this warning
+    !WARNING: The actual argument for DIM= is optional, pointer, or allocatable, and may not be absent during execution; parenthesize to silence this warning [-Wno-optional-must-be-present]
     f13 = sum(a,dim=d)
   end function
 end module
diff --git a/flang/test/Semantics/dosemantics02.f90 b/flang/test/Semantics/dosemantics02.f90
index d6075a8a3f8f8..5cb1edf716d07 100644
--- a/flang/test/Semantics/dosemantics02.f90
+++ b/flang/test/Semantics/dosemantics02.f90
@@ -23,12 +23,12 @@ SUBROUTINE s1()
   INTEGER, PARAMETER :: constInt = 0
 
   ! Warn on this one for backwards compatibility
-  !WARNING: DO step expression should not be zero
+  !WARNING: DO step expression should not be zero [-Wno-zero-do-step]
   DO 10 I = 1, 10, 0
   10 CONTINUE
 
   ! Warn on this one for backwards compatibility
-  !WARNING: DO step expression should not be zero
+  !WARNING: DO step expression should not be zero [-Wno-zero-do-step]
   DO 20 I = 1, 10, 5 - 5
   20 CONTINUE
 
diff --git a/flang/test/Semantics/dosemantics03.f90 b/flang/test/Semantics/dosemantics03.f90
index a36c86b202c48..56c7f48ddb89e 100644
--- a/flang/test/Semantics/dosemantics03.f90
+++ b/flang/test/Semantics/dosemantics03.f90
@@ -50,13 +50,13 @@ END FUNCTION ifunc
   END DO
 
 ! REAL DO variable
-!PORTABILITY: DO controls should be INTEGER
+!PORTABILITY: DO controls should be INTEGER [-Wno-real-do-controls]
   DO rvar = 1, 10, 3
     PRINT *, "rvar is: ", rvar
   END DO
 
 ! DOUBLE PRECISISON DO variable
-!PORTABILITY: DO controls should be INTEGER
+!PORTABILITY: DO controls should be INTEGER [-Wno-real-do-controls]
   DO dvar = 1, 10, 3
     PRINT *, "dvar is: ", dvar
   END DO
@@ -69,14 +69,14 @@ END FUNCTION ifunc
 
 ! Pointer to REAL DO variable
   ALLOCATE(prvar)
-!PORTABILITY: DO controls should be INTEGER
+!PORTABILITY: DO controls should be INTEGER [-Wno-real-do-controls]
   DO prvar = 1, 10, 3
     PRINT *, "prvar is: ", prvar
   END DO
 
 ! Pointer to DOUBLE PRECISION DO variable
   ALLOCATE(pdvar)
-!PORTABILITY: DO controls should be INTEGER
+!PORTABILITY: DO controls should be INTEGER [-Wno-real-do-controls]
   DO pdvar = 1, 10, 3
     PRINT *, "pdvar is: ", pdvar
   END DO
@@ -148,26 +148,26 @@ END FUNCTION ifunc
   END DO
 
 ! Shared association REAL DO variable
-!PORTABILITY: DO controls should be INTEGER
+!PORTABILITY: DO controls should be INTEGER [-Wno-real-do-controls]
   DO realvarshare = 1, 10, 3
     PRINT *, "ivar is: ", ivar
   END DO
 
 ! Shared association DOUBLE PRECISION DO variable
-!PORTABILITY: DO controls should be INTEGER
+!PORTABILITY: DO controls should be INTEGER [-Wno-real-do-controls]
   DO dpvarshare = 1, 10, 3
     PRINT *, "ivar is: ", ivar
   END DO
 
 ! Initial expressions
 ! REAL initial expression
-!PORTABILITY: DO controls should be INTEGER
+!PORTABILITY: DO controls should be INTEGER [-Wno-real-do-controls]
   DO ivar = rvar, 10, 3
     PRINT *, "ivar is: ", ivar
   END DO
 
 ! DOUBLE PRECISION initial expression
-!PORTABILITY: DO controls should be INTEGER
+!PORTABILITY: DO controls should be INTEGER [-Wno-real-do-controls]
   DO ivar = dvar, 10, 3
     PRINT *, "ivar is: ", ivar
   END DO
@@ -178,13 +178,13 @@ END FUNCTION ifunc
   END DO
 
 ! Pointer to REAL initial expression
-!PORTABILITY: DO controls should be INTEGER
+!PORTABILITY: DO controls should be INTEGER [-Wno-real-do-controls]
   DO ivar = prvar, 10, 3
     PRINT *, "ivar is: ", ivar
   END DO
 
 ! Pointer to DOUBLE PRECISION initial expression
-!PORTABILITY: DO controls should be INTEGER
+!PORTABILITY: DO controls should be INTEGER [-Wno-real-do-controls]
   DO ivar = pdvar, 10, 3
     PRINT *, "ivar is: ", ivar
   END DO
@@ -221,13 +221,13 @@ END FUNCTION ifunc
 
 ! Final expression
 ! REAL final expression
-!PORTABILITY: DO controls should be INTEGER
+!PORTABILITY: DO controls should be INTEGER [-Wno-real-do-controls]
   DO ivar = 1, rvar, 3
     PRINT *, "ivar is: ", ivar
   END DO
 
 ! DOUBLE PRECISION final expression
-!PORTABILITY: DO controls should be INTEGER
+!PORTABILITY: DO controls should be INTEGER [-Wno-real-do-controls]
   DO ivar = 1, dvar, 3
     PRINT *, "ivar is: ", ivar
   END DO
@@ -238,13 +238,13 @@ END FUNCTION ifunc
   END DO
 
 ! Pointer to REAL final expression
-!PORTABILITY: DO controls should be INTEGER
+!PORTABILITY: DO controls should be INTEGER [-Wno-real-do-controls]
   DO ivar = 1, prvar, 3
     PRINT *, "ivar is: ", ivar
   END DO
 
 ! Pointer to DOUBLE PRECISION final expression
-!PORTABILITY: DO controls should be INTEGER
+!PORTABILITY: DO controls should be INTEGER [-Wno-real-do-controls]
   DO ivar = pdvar, 10, 3
     PRINT *, "ivar is: ", ivar
   END DO
@@ -263,13 +263,13 @@ END FUNCTION ifunc
 
 ! Step expression
 ! REAL step expression
-!PORTABILITY: DO controls should be INTEGER
+!PORTABILITY: DO controls should be INTEGER [-Wno-real-do-controls]
   DO ivar = 1, 10, rvar
     PRINT *, "ivar is: ", ivar
   END DO
 
 ! DOUBLE PRECISION step expression
-!PORTABILITY: DO controls should be INTEGER
+!PORTABILITY: DO controls should be INTEGER [-Wno-real-do-controls]
   DO ivar = 1, 10, dvar
     PRINT *, "ivar is: ", ivar
   END DO
@@ -280,13 +280,13 @@ END FUNCTION ifunc
   END DO
 
 ! Pointer to REAL step expression
-!PORTABILITY: DO controls should be INTEGER
+!PORTABILITY: DO controls should be INTEGER [-Wno-real-do-controls]
   DO ivar = 1, 10, prvar
     PRINT *, "ivar is: ", ivar
   END DO
 
 ! Pointer to DOUBLE PRECISION step expression
-!PORTABILITY: DO controls should be INTEGER
+!PORTABILITY: DO controls should be INTEGER [-Wno-real-do-controls]
   DO ivar = 1, 10, pdvar
     PRINT *, "ivar is: ", ivar
   END DO
diff --git a/flang/test/Semantics/dosemantics12.f90 b/flang/test/Semantics/dosemantics12.f90
index 1757ade4b7c8f..c2a69beac8df7 100644
--- a/flang/test/Semantics/dosemantics12.f90
+++ b/flang/test/Semantics/dosemantics12.f90
@@ -316,7 +316,7 @@ subroutine s9()
   ! Technically non-conformant (F'2023 19.4 p8)
   do concurrent (ivar = 1:10)
     print *, "hello"
-    !PORTABILITY: Index variable 'ivar' should not also be an index in an enclosing FORALL or DO CONCURRENT
+    !PORTABILITY: Index variable 'ivar' should not also be an index in an enclosing FORALL or DO CONCURRENT [-Wno-odd-index-variable-restrictions]
     do concurrent (ivar = 1:10)
       print *, "hello"
     end do
@@ -392,7 +392,7 @@ subroutine s12()
 
   call intentInOutSub(jvar, ivar)
   do ivar = 1,10
-    !WARNING: Possible redefinition of DO variable 'ivar'
+    !WARNING: Possible redefinition of DO variable 'ivar' [-Wno-index-var-redefinition]
     call intentInOutSub(jvar, ivar)
   end do
 
@@ -437,7 +437,7 @@ subroutine s13()
   end do
 
   do ivar = 1, 10
-    !WARNING: Possible redefinition of DO variable 'ivar'
+    !WARNING: Possible redefinition of DO variable 'ivar' [-Wno-index-var-redefinition]
     jvar = intentInOutFunc(ivar)
   end do
 
diff --git a/flang/test/Semantics/expr-errors05.f90 b/flang/test/Semantics/expr-errors05.f90
index 0328165a7921e..d2a3619c206b4 100644
--- a/flang/test/Semantics/expr-errors05.f90
+++ b/flang/test/Semantics/expr-errors05.f90
@@ -1,16 +1,16 @@
 ! RUN: %python %S/test_errors.py %s %flang_fc1 -Werror -pedantic
-!PORTABILITY: nonstandard usage: generalized COMPLEX constructor
-!PORTABILITY: Real part of complex constructor is not scalar
+!PORTABILITY: nonstandard usage: generalized COMPLEX constructor [-Wno-complex-constructor]
+!PORTABILITY: Real part of complex constructor is not scalar [-Wno-complex-constructor]
 complex, parameter :: z1(*) = ([1.,2.], 3.)
-!PORTABILITY: nonstandard usage: generalized COMPLEX constructor
-!PORTABILITY: Imaginary part of complex constructor is not scalar
+!PORTABILITY: nonstandard usage: generalized COMPLEX constructor [-Wno-complex-constructor]
+!PORTABILITY: Imaginary part of complex constructor is not scalar [-Wno-complex-constructor]
 complex, parameter :: z2(*) = (4., [5.,6.])
 real, parameter :: aa(*) = [7.,8.]
-!PORTABILITY: Real part of complex literal constant is not scalar
+!PORTABILITY: Real part of complex literal constant is not scalar [-Wno-complex-constructor]
 complex, parameter :: z3(*) = (aa, 9.)
-!PORTABILITY: Imaginary part of complex literal constant is not scalar
+!PORTABILITY: Imaginary part of complex literal constant is not scalar [-Wno-complex-constructor]
 complex, parameter :: z4(*) = (10., aa)
 !We need a nonzero exit status to make test_errors.py look at messages :-(
-!WARNING: division by zero
+!WARNING: division by zero [-Wno-folding-exception]
 real, parameter :: xxx = 1./0.
 end
diff --git a/flang/test/Semantics/expr-errors06.f90 b/flang/test/Semantics/expr-errors06.f90
index 7d4283d35cdcb..aabe5b7e8a767 100644
--- a/flang/test/Semantics/expr-errors06.f90
+++ b/flang/test/Semantics/expr-errors06.f90
@@ -43,6 +43,6 @@ subroutine subr(da)
   print *, empty(1:0,1) ! ok
   print *, empty(:,1) ! ok
   print *, empty(i:j,k) ! ok
-  !WARNING: Empty array dimension 1 should not be subscripted as an element or non-empty array section
+  !WARNING: Empty array dimension 1 should not be subscripted as an element or non-empty array section [-Wno-subscripted-empty-array]
   print *, empty(i,1)
 end
diff --git a/flang/test/Semantics/final03.f90 b/flang/test/Semantics/final03.f90
index 3c402540152bc..7af6cbf02b709 100644
--- a/flang/test/Semantics/final03.f90
+++ b/flang/test/Semantics/final03.f90
@@ -20,7 +20,7 @@ program test
   type(pdt(1)) x1(1)
   type(pdt(2)) x2(1)
   type(pdt(3)) x3(1)
-  !PORTABILITY: Variable 'x1([INTEGER(8)::1_8])' has a vector subscript and will be finalized by non-elemental subroutine 'finalarr'
+  !PORTABILITY: Variable 'x1([INTEGER(8)::1_8])' has a vector subscript and will be finalized by non-elemental subroutine 'finalarr' [-Wno-vector-subscript-finalization]
   x1([1]) = pdt(1)()
   x2([1]) = pdt(2)() ! ok, doesn't match either
   x3([1]) = pdt(3)() ! ok, calls finalElem
diff --git a/flang/test/Semantics/forall01.f90 b/flang/test/Semantics/forall01.f90
index 72ad9ecd39471..b7bd9dddf654c 100644
--- a/flang/test/Semantics/forall01.f90
+++ b/flang/test/Semantics/forall01.f90
@@ -10,7 +10,7 @@ subroutine forall1
     a(i) = i
   end forall
   forall (j=1:8)
-    !PORTABILITY: Index variable 'j' should not also be an index in an enclosing FORALL or DO CONCURRENT
+    !PORTABILITY: Index variable 'j' should not also be an index in an enclosing FORALL or DO CONCURRENT [-Wno-odd-index-variable-restrictions]
     forall (j=1:9)
     end forall
   end forall
@@ -41,7 +41,7 @@ subroutine forall3
   forall(i=1:10)
     forall(j=1:10)
       !ERROR: Cannot redefine FORALL variable 'i'
-      !WARNING: FORALL index variable 'j' not used on left-hand side of assignment
+      !WARNING: FORALL index variable 'j' not used on left-hand side of assignment [-Wno-unused-forall-index]
       i = 1
     end forall
   end forall
@@ -80,20 +80,20 @@ subroutine forall5
     x(i) = y(i)
   end forall
   forall(i=1:10)
-    !WARNING: FORALL index variable 'i' not used on left-hand side of assignment
+    !WARNING: FORALL index variable 'i' not used on left-hand side of assignment [-Wno-unused-forall-index]
     x = y
     forall(j=1:10)
-      !WARNING: FORALL index variable 'j' not used on left-hand side of assignment
+      !WARNING: FORALL index variable 'j' not used on left-hand side of assignment [-Wno-unused-forall-index]
       x(i) = y(i)
-      !WARNING: FORALL index variable 'i' not used on left-hand side of assignment
+      !WARNING: FORALL index variable 'i' not used on left-hand side of assignment [-Wno-unused-forall-index]
       x(j) = y(j)
     endforall
   endforall
   do concurrent(i=1:10)
     x = y
     !Odd rule from F'2023 19.4 p8
-    !PORTABILITY: Index variable 'i' should not also be an index in an enclosing FORALL or DO CONCURRENT
-    !WARNING: FORALL index variable 'i' not used on left-hand side of assignment
+    !PORTABILITY: Index variable 'i' should not also be an index in an enclosing FORALL or DO CONCURRENT [-Wno-odd-index-variable-restrictions]
+    !WARNING: FORALL index variable 'i' not used on left-hand side of assignment [-Wno-unused-forall-index]
     forall(i=1:10) x = y
   end do
 end
@@ -106,7 +106,7 @@ subroutine forall6
   real, target :: b(10)
   forall(i=1:10)
     a(i)%p => b(i)
-    !WARNING: FORALL index variable 'i' not used on left-hand side of assignment
+    !WARNING: FORALL index variable 'i' not used on left-hand side of assignment [-Wno-unused-forall-index]
     a(1)%p => b(i)
   end forall
 end
@@ -116,20 +116,20 @@ subroutine forall7(x)
   real :: a(10)
   class(*) :: x
   associate (j => iarr(1))
-    !PORTABILITY: Index variable 'j' should be a scalar object or common block if it is present in the enclosing scope
+    !PORTABILITY: Index variable 'j' should be a scalar object or common block if it is present in the enclosing scope [-Wno-odd-index-variable-restrictions]
     forall (j=1:size(a))
       a(j) = a(j) + 1
     end forall
   end associate
   associate (j => iarr(1) + 1)
-    !PORTABILITY: Index variable 'j' should be a scalar object or common block if it is present in the enclosing scope
+    !PORTABILITY: Index variable 'j' should be a scalar object or common block if it is present in the enclosing scope [-Wno-odd-index-variable-restrictions]
     forall (j=1:size(a))
       a(j) = a(j) + 1
     end forall
   end associate
   select type (j => x)
   type is (integer)
-    !PORTABILITY: Index variable 'j' should be a scalar object or common block if it is present in the enclosing scope
+    !PORTABILITY: Index variable 'j' should be a scalar object or common block if it is present in the enclosing scope [-Wno-odd-index-variable-restrictions]
     forall (j=1:size(a))
       a(j) = a(j) + 1
     end forall
diff --git a/flang/test/Semantics/forall02.f90 b/flang/test/Semantics/forall02.f90
index c4f4311a175a3..7c04fb6a02e36 100644
--- a/flang/test/Semantics/forall02.f90
+++ b/flang/test/Semantics/forall02.f90
@@ -35,7 +35,7 @@ subroutine s1()
 
     ! Error to invoke an IMPURE FINAL procedure in a FORALL
     forall (i = 1:10)
-      !WARNING: FORALL index variable 'i' not used on left-hand side of assignment
+      !WARNING: FORALL index variable 'i' not used on left-hand side of assignment [-Wno-unused-forall-index]
       !ERROR: Impure procedure 'impuresub' is referenced by finalization in a FORALL
       ifvar = ifvar1
     end forall
@@ -46,7 +46,7 @@ subroutine s1()
     end forall
 
     forall (i = 1:5)
-      !WARNING: FORALL index variable 'i' not used on left-hand side of assignment
+      !WARNING: FORALL index variable 'i' not used on left-hand side of assignment [-Wno-unused-forall-index]
       !ERROR: Impure procedure 'impuresubrank1' is referenced by finalization in a FORALL
       ifArr1 = if0
     end forall
@@ -57,7 +57,7 @@ subroutine s1()
     end forall
 
     forall (i = 1:5)
-      !WARNING: FORALL index variable 'i' not used on left-hand side of assignment
+      !WARNING: FORALL index variable 'i' not used on left-hand side of assignment [-Wno-unused-forall-index]
       !ERROR: Impure procedure 'impuresubrank2' is referenced by finalization in a FORALL
       ifArr2(:,:) = if0
     end forall
diff --git a/flang/test/Semantics/generic03.f90 b/flang/test/Semantics/generic03.f90
index 829780f52174f..6f92fb6825690 100644
--- a/flang/test/Semantics/generic03.f90
+++ b/flang/test/Semantics/generic03.f90
@@ -15,7 +15,7 @@ integer function f1(x, j)
 
 program test
   use m1
-  !WARNING: Generic interface 'g1' has both a function and a subroutine
+  !WARNING: Generic interface 'g1' has both a function and a subroutine [-Wno-subroutine-and-function-specifics]
   interface g1
     subroutine s1(x, a)
       import t1
diff --git a/flang/test/Semantics/generic06.f90 b/flang/test/Semantics/generic06.f90
index b47d442f3549e..a04e8a208b3d8 100644
--- a/flang/test/Semantics/generic06.f90
+++ b/flang/test/Semantics/generic06.f90
@@ -1,11 +1,11 @@
 ! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
 module m
-  !PORTABILITY: Specific procedure 'sin' of generic interface 'yintercept' should not be INTRINSIC
+  !PORTABILITY: Specific procedure 'sin' of generic interface 'yintercept' should not be INTRINSIC [-Wno-intrinsic-as-specific]
   intrinsic sin
   interface yIntercept
     procedure sin
   end interface
-  !PORTABILITY: Specific procedure 'cos' of generic interface 'xintercept' should not be INTRINSIC
+  !PORTABILITY: Specific procedure 'cos' of generic interface 'xintercept' should not be INTRINSIC [-Wno-intrinsic-as-specific]
   intrinsic cos
   generic :: xIntercept => cos
 end module
diff --git a/flang/test/Semantics/global01.f90 b/flang/test/Semantics/global01.f90
index ab3edf9ef805f..ddc8ba0493e2e 100644
--- a/flang/test/Semantics/global01.f90
+++ b/flang/test/Semantics/global01.f90
@@ -30,7 +30,7 @@ recursive function global6()
 
 program test
   interface
-    !WARNING: The global subprogram 'global1' is not compatible with its local procedure declaration (incompatible dummy argument #1: incompatible dummy data object types: INTEGER(4) vs REAL(4))
+    !WARNING: The global subprogram 'global1' is not compatible with its local procedure declaration (incompatible dummy argument #1: incompatible dummy data object types: INTEGER(4) vs REAL(4)) [-Wno-external-interface-mismatch]
     subroutine global1(x)
       real, intent(in) :: x
     end subroutine
@@ -43,7 +43,7 @@ subroutine global3(x) bind(c,name="abc")
     subroutine global4(x) ! not PURE, but that's ok
       integer, intent(in) :: x
     end subroutine
-    !WARNING: The global subprogram 'global5' is not compatible with its local procedure declaration (incompatible procedure attributes: Pure)
+    !WARNING: The global subprogram 'global5' is not compatible with its local procedure declaration (incompatible procedure attributes: Pure) [-Wno-external-interface-mismatch]
     pure subroutine global5(x)
       integer, intent(in) :: x
     end subroutine
diff --git a/flang/test/Semantics/ichar01.f90 b/flang/test/Semantics/ichar01.f90
index 5eb25a97e6d93..e20a12174d3ab 100644
--- a/flang/test/Semantics/ichar01.f90
+++ b/flang/test/Semantics/ichar01.f90
@@ -5,9 +5,9 @@
 print *, iachar('')
 print *, ichar('a')
 print *, iachar('a')
-!PORTABILITY: Character in intrinsic function ichar should have length one
+!PORTABILITY: Character in intrinsic function ichar should have length one [-Wno-portability]
 print *, ichar('ab')
-!PORTABILITY: Character in intrinsic function iachar should have length one
+!PORTABILITY: Character in intrinsic function iachar should have length one [-Wno-portability]
 print *, iachar('ab')
 end
 
diff --git a/flang/test/Semantics/ignore_tkr01.f90 b/flang/test/Semantics/ignore_tkr01.f90
index 2af4974b1c038..5b5209d619b88 100644
--- a/flang/test/Semantics/ignore_tkr01.f90
+++ b/flang/test/Semantics/ignore_tkr01.f90
@@ -53,13 +53,13 @@ subroutine t8(x)
 
     subroutine t9(x)
 !dir$ ignore_tkr x
-!WARNING: !DIR$ IGNORE_TKR should not apply to an allocatable or pointer
+!WARNING: !DIR$ IGNORE_TKR should not apply to an allocatable or pointer [-Wno-ignore-tkr-usage]
       real, intent(in), allocatable :: x
     end
 
     subroutine t10(x)
 !dir$ ignore_tkr x
-!WARNING: !DIR$ IGNORE_TKR should not apply to an allocatable or pointer
+!WARNING: !DIR$ IGNORE_TKR should not apply to an allocatable or pointer [-Wno-ignore-tkr-usage]
       real, intent(in), pointer :: x
     end
 
@@ -88,7 +88,7 @@ elemental subroutine t13(x)
 
     subroutine t14(x)
 !dir$ ignore_tkr(r) x
-!WARNING: !DIR$ IGNORE_TKR(R) should not apply to a dummy argument passed via descriptor
+!WARNING: !DIR$ IGNORE_TKR(R) should not apply to a dummy argument passed via descriptor [-Wno-ignore-tkr-usage]
       real x(:)
     end
 
@@ -145,7 +145,7 @@ subroutine t20(x)
 
   subroutine t22(x)
 !dir$ ignore_tkr(r) x
-!WARNING: !DIR$ IGNORE_TKR(R) is not meaningful for an assumed-rank array
+!WARNING: !DIR$ IGNORE_TKR(R) is not meaningful for an assumed-rank array [-Wno-ignore-tkr-usage]
     real x(..)
   end
 
@@ -198,7 +198,7 @@ program test
   !ERROR: Actual argument type 'INTEGER(4)' is not compatible with dummy argument type 'REAL(4)'
   call t3(1)
   call t3(dx)
-  !ERROR: passing Hollerith or character literal as if it were BOZ
+  !ERROR: passing Hollerith or character literal as if it were BOZ [-Wno-hollerith-or-character-as-boz]
   call t3('a')
   !ERROR: Actual argument type 'COMPLEX(4)' is not compatible with dummy argument type 'REAL(4)'
   call t3((1.,2.))
diff --git a/flang/test/Semantics/int-literals.f90 b/flang/test/Semantics/int-literals.f90
index 6d4a63e4bba71..21cfe692a6a15 100644
--- a/flang/test/Semantics/int-literals.f90
+++ b/flang/test/Semantics/int-literals.f90
@@ -30,9 +30,9 @@
 complex, parameter :: okz4a = (+2147483648_8, 0)
 
 complex, parameter :: okj4d = 2147483647, okz4d = (+2147483647, -2147483648)
-!WARNING: Integer literal is too large for default INTEGER(KIND=4); assuming INTEGER(KIND=8)
+!WARNING: Integer literal is too large for default INTEGER(KIND=4); assuming INTEGER(KIND=8) [-Wno-big-int-literals]
 complex, parameter :: badj4dext = 2147483648
-!WARNING: Integer literal is too large for default INTEGER(KIND=4); assuming INTEGER(KIND=8)
+!WARNING: Integer literal is too large for default INTEGER(KIND=4); assuming INTEGER(KIND=8) [-Wno-big-int-literals]
 complex, parameter :: badz4dext = (+2147483648, 0)
 
 complex, parameter :: okj8 = 9223372036854775807_8, okz8 = (+9223372036854775807_8, -9223372036854775808_8)
diff --git a/flang/test/Semantics/intrinsics02.f90 b/flang/test/Semantics/intrinsics02.f90
index 0b1f7c13a1564..bf45469d531b4 100644
--- a/flang/test/Semantics/intrinsics02.f90
+++ b/flang/test/Semantics/intrinsics02.f90
@@ -17,7 +17,7 @@ pure real function mycos(x)
 end
 subroutine sameIntrinsic1
   use explicit
-  !WARNING: Use-associated 'cos' already has 'INTRINSIC' attribute
+  !WARNING: Use-associated 'cos' already has 'INTRINSIC' attribute [-Wno-redundant-attribute]
   intrinsic cos
   real :: one = cos(0.)
 end
diff --git a/flang/test/Semantics/kinds05b.f90 b/flang/test/Semantics/kinds05b.f90
index 3927829bbaab6..63fd37df8e40e 100644
--- a/flang/test/Semantics/kinds05b.f90
+++ b/flang/test/Semantics/kinds05b.f90
@@ -8,8 +8,8 @@ subroutine s
   real :: realvar3 = 4.0_8
   real :: realvar4 = 4.0E6_4
   real :: realvar5 = 4.0E6_8
-  !PORTABILITY: Explicit kind parameter together with non-'E' exponent letter is not standard
+  !PORTABILITY: Explicit kind parameter together with non-'E' exponent letter is not standard [-Wno-exponent-matching-kind-param]
   real :: realvar6 = 4.0D6_8
-  !WARNING: Explicit kind parameter on real constant disagrees with exponent letter 'd'
+  !WARNING: Explicit kind parameter on real constant disagrees with exponent letter 'd' [-Wno-exponent-matching-kind-param]
   real :: realvar7 = 4.0D6_4
 end subroutine s
diff --git a/flang/test/Semantics/label18.f90 b/flang/test/Semantics/label18.f90
index a9f3e50237f98..7b03d39982abb 100644
--- a/flang/test/Semantics/label18.f90
+++ b/flang/test/Semantics/label18.f90
@@ -9,10 +9,10 @@ program main
 1 end if
   if (.true.) then
     do j = 1, 2
-      !WARNING: Label '1' is in a construct that should not be used as a branch target here
+      !WARNING: Label '1' is in a construct that should not be used as a branch target here [-Wno-branch-into-construct]
       goto 1
     end do
   end if
-  !WARNING: Label '1' is in a construct that should not be used as a branch target here
+  !WARNING: Label '1' is in a construct that should not be used as a branch target here [-Wno-branch-into-construct]
   goto 1
 end
diff --git a/flang/test/Semantics/local-vs-global.f90 b/flang/test/Semantics/local-vs-global.f90
index 3f7e9339639cc..e334bc85caa6a 100644
--- a/flang/test/Semantics/local-vs-global.f90
+++ b/flang/test/Semantics/local-vs-global.f90
@@ -46,24 +46,24 @@ function implicit_func_before_2(a)
 
 program test
   external justfine ! OK to name a BLOCK DATA if not called
-  !WARNING: The global entity 'module_before_1' corresponding to the local procedure 'module_before_1' is not a callable subprogram
+  !WARNING: The global entity 'module_before_1' corresponding to the local procedure 'module_before_1' is not a callable subprogram [-Wno-external-name-conflict]
   external module_before_1
-  !WARNING: The global entity 'block_data_before_1' corresponding to the local procedure 'block_data_before_1' is not a callable subprogram
+  !WARNING: The global entity 'block_data_before_1' corresponding to the local procedure 'block_data_before_1' is not a callable subprogram [-Wno-external-name-conflict]
   external block_data_before_1
-  !WARNING: The global subprogram 'explicit_before_1' should not be referenced via the implicit interface 'explicit_before_1'
+  !WARNING: The global subprogram 'explicit_before_1' should not be referenced via the implicit interface 'explicit_before_1' [-Wno-external-interface-mismatch]
   external explicit_before_1
   external implicit_before_1
-  !WARNING: The global subprogram 'explicit_func_before_1' should not be referenced via the implicit interface 'explicit_func_before_1'
+  !WARNING: The global subprogram 'explicit_func_before_1' should not be referenced via the implicit interface 'explicit_func_before_1' [-Wno-external-interface-mismatch]
   external explicit_func_before_1
   external implicit_func_before_1
-  !WARNING: The global entity 'module_after_1' corresponding to the local procedure 'module_after_1' is not a callable subprogram
+  !WARNING: The global entity 'module_after_1' corresponding to the local procedure 'module_after_1' is not a callable subprogram [-Wno-external-name-conflict]
   external module_after_1
-  !WARNING: The global entity 'block_data_after_1' corresponding to the local procedure 'block_data_after_1' is not a callable subprogram
+  !WARNING: The global entity 'block_data_after_1' corresponding to the local procedure 'block_data_after_1' is not a callable subprogram [-Wno-external-name-conflict]
   external block_data_after_1
-  !WARNING: The global subprogram 'explicit_after_1' should not be referenced via the implicit interface 'explicit_after_1'
+  !WARNING: The global subprogram 'explicit_after_1' should not be referenced via the implicit interface 'explicit_after_1' [-Wno-external-interface-mismatch]
   external explicit_after_1
   external implicit_after_1
-  !WARNING: The global subprogram 'explicit_func_after_1' should not be referenced via the implicit interface 'explicit_func_after_1'
+  !WARNING: The global subprogram 'explicit_func_after_1' should not be referenced via the implicit interface 'explicit_func_after_1' [-Wno-external-interface-mismatch]
   external explicit_func_after_1
   external implicit_func_after_1
   call module_before_1
@@ -76,20 +76,20 @@ program test
   !ERROR: References to the procedure 'explicit_before_2' require an explicit interface
   !BECAUSE: a dummy argument has the allocatable, asynchronous, optional, pointer, target, value, or volatile attribute
   call explicit_before_2(1.)
-  !WARNING: If the procedure's interface were explicit, this reference would be in error
+  !WARNING: If the procedure's interface were explicit, this reference would be in error [-Wno-known-bad-implicit-interface]
   !BECAUSE: Dummy argument 'a=' (#1) is not OPTIONAL and is not associated with an actual argument in this procedure reference
   call implicit_before_1
-  !WARNING: If the procedure's interface were explicit, this reference would be in error
+  !WARNING: If the procedure's interface were explicit, this reference would be in error [-Wno-known-bad-implicit-interface]
   !BECAUSE: Dummy argument 'a=' (#1) is not OPTIONAL and is not associated with an actual argument in this procedure reference
   call implicit_before_2
   print *, explicit_func_before_1(1.)
   !ERROR: References to the procedure 'explicit_func_before_2' require an explicit interface
   !BECAUSE: a dummy argument has the allocatable, asynchronous, optional, pointer, target, value, or volatile attribute
   print *, explicit_func_before_2(1.)
-  !WARNING: If the procedure's interface were explicit, this reference would be in error
+  !WARNING: If the procedure's interface were explicit, this reference would be in error [-Wno-known-bad-implicit-interface]
   !BECAUSE: Dummy argument 'a=' (#1) is not OPTIONAL and is not associated with an actual argument in this procedure reference
   print *, implicit_func_before_1()
-  !WARNING: If the procedure's interface were explicit, this reference would be in error
+  !WARNING: If the procedure's interface were explicit, this reference would be in error [-Wno-known-bad-implicit-interface]
   !BECAUSE: Dummy argument 'a=' (#1) is not OPTIONAL and is not associated with an actual argument in this procedure reference
   print *, implicit_func_before_2()
   call module_after_1
@@ -100,20 +100,20 @@ program test
   !ERROR: References to the procedure 'explicit_after_2' require an explicit interface
   !BECAUSE: a dummy argument has the allocatable, asynchronous, optional, pointer, target, value, or volatile attribute
   call explicit_after_2(1.)
-  !WARNING: If the procedure's interface were explicit, this reference would be in error
+  !WARNING: If the procedure's interface were explicit, this reference would be in error [-Wno-known-bad-implicit-interface]
   !BECAUSE: Dummy argument 'a=' (#1) is not OPTIONAL and is not associated with an actual argument in this procedure reference
   call implicit_after_1
-  !WARNING: If the procedure's interface were explicit, this reference would be in error
+  !WARNING: If the procedure's interface were explicit, this reference would be in error [-Wno-known-bad-implicit-interface]
   !BECAUSE: Dummy argument 'a=' (#1) is not OPTIONAL and is not associated with an actual argument in this procedure reference
   call implicit_after_2
   print *, explicit_func_after_1(1.)
   !ERROR: References to the procedure 'explicit_func_after_2' require an explicit interface
   !BECAUSE: a dummy argument has the allocatable, asynchronous, optional, pointer, target, value, or volatile attribute
   print *, explicit_func_after_2(1.)
-  !WARNING: If the procedure's interface were explicit, this reference would be in error
+  !WARNING: If the procedure's interface were explicit, this reference would be in error [-Wno-known-bad-implicit-interface]
   !BECAUSE: Dummy argument 'a=' (#1) is not OPTIONAL and is not associated with an actual argument in this procedure reference
   print *, implicit_func_after_1()
-  !WARNING: If the procedure's interface were explicit, this reference would be in error
+  !WARNING: If the procedure's interface were explicit, this reference would be in error [-Wno-known-bad-implicit-interface]
   !BECAUSE: Dummy argument 'a=' (#1) is not OPTIONAL and is not associated with an actual argument in this procedure reference
   print *, implicit_func_after_2()
 end program
diff --git a/flang/test/Semantics/long-name.f90 b/flang/test/Semantics/long-name.f90
index c406e366f76d4..cacf36b1080a6 100644
--- a/flang/test/Semantics/long-name.f90
+++ b/flang/test/Semantics/long-name.f90
@@ -1,14 +1,14 @@
 ! RUN: %python %S/test_errors.py %s %flang_fc1 -Werror -pedantic
 
-!PORTABILITY: aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggg1 has length 64, which is greater than the maximum name length 63
+!PORTABILITY: aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggg1 has length 64, which is greater than the maximum name length 63 [-Wno-long-names]
 program aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggg1
 
-  !PORTABILITY: aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggg2 has length 64, which is greater than the maximum name length 63
+  !PORTABILITY: aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggg2 has length 64, which is greater than the maximum name length 63 [-Wno-long-names]
   integer :: aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggg2
 
   integer :: aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggg
 
-  !PORTABILITY: aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggg3 has length 64, which is greater than the maximum name length 63
+  !PORTABILITY: aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggg3 has length 64, which is greater than the maximum name length 63 [-Wno-long-names]
   call aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggg3
 
 end
diff --git a/flang/test/Semantics/modfile43.f90 b/flang/test/Semantics/modfile43.f90
index 1a50e94698f63..44cc56cbf7a81 100644
--- a/flang/test/Semantics/modfile43.f90
+++ b/flang/test/Semantics/modfile43.f90
@@ -5,7 +5,7 @@ module iso_fortran_env
 end module
 module m1
   use, intrinsic :: iso_fortran_env, only: int32
-  !PORTABILITY: Should not USE the non-intrinsic module 'iso_fortran_env' in the same scope as a USE of the intrinsic module
+  !PORTABILITY: Should not USE the non-intrinsic module 'iso_fortran_env' in the same scope as a USE of the intrinsic module [-Wno-misc-use-extensions]
   use, non_intrinsic :: iso_fortran_env, only: user_defined_123
 end module
 module m2
diff --git a/flang/test/Semantics/null-init.f90 b/flang/test/Semantics/null-init.f90
index ad3f91679a427..f3e3613eb3dee 100644
--- a/flang/test/Semantics/null-init.f90
+++ b/flang/test/Semantics/null-init.f90
@@ -37,7 +37,7 @@ module m6
 
 module m7
   interface
-    !WARNING: The external interface 'null' is not compatible with an earlier definition (incompatible procedure attributes: ImplicitInterface)
+    !WARNING: The external interface 'null' is not compatible with an earlier definition (incompatible procedure attributes: ImplicitInterface) [-Wno-external-interface-mismatch]
     function null() result(p)
       integer, pointer :: p
     end function
diff --git a/flang/test/Semantics/null01.f90 b/flang/test/Semantics/null01.f90
index b21ee91a0be0a..0e7e00adb5c8b 100644
--- a/flang/test/Semantics/null01.f90
+++ b/flang/test/Semantics/null01.f90
@@ -103,9 +103,9 @@ function f3()
   dt3x = dt3(pps1=null(mold=dt2x%pps0))
   dt3x = dt3(pps1=null(mold=dt3x%pps1))
   dt4x = dt4(null()) ! ok
-  !PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'ra0'
+  !PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'ra0' [-Wno-null-mold-allocatable-component-value]
   dt4x = dt4(null(rp0))
-  !PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'ra0'
+  !PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'ra0' [-Wno-null-mold-allocatable-component-value]
   !ERROR: Rank-1 array value is not compatible with scalar component 'ra0'
   dt4x = dt4(null(rp1))
   !ERROR: A NULL procedure pointer may not be used as the value for component 'ra0'
@@ -133,7 +133,7 @@ function f3()
   print *, same_type_as(null(dt5p), null(dt4p)) ! ok
   !ERROR: A NULL() pointer is not allowed for 'source=' intrinsic argument
   print *, transfer(null(rp0),ip0)
-  !WARNING: Source of TRANSFER contains allocatable or pointer component %ra0
+  !WARNING: Source of TRANSFER contains allocatable or pointer component %ra0 [-Wno-pointer-component-transfer-arg]
   print *, transfer(dt4(null()),[0])
   !ERROR: NULL() may not be used as an expression in this context
   select case(null(ip0))
diff --git a/flang/test/Semantics/pointer01.f90 b/flang/test/Semantics/pointer01.f90
index cb860f3a3f437..34b7e6c3cdbae 100644
--- a/flang/test/Semantics/pointer01.f90
+++ b/flang/test/Semantics/pointer01.f90
@@ -7,7 +7,7 @@ subroutine msubr
 end module
 program main
   use m
-  !PORTABILITY: Name 'main' declared in a main program should not have the same name as the main program
+  !PORTABILITY: Name 'main' declared in a main program should not have the same name as the main program [-Wno-benign-name-clash]
   pointer main
   !ERROR: Cannot change POINTER attribute on use-associated 'mobj'
   pointer mobj
diff --git a/flang/test/Semantics/procinterface02.f90 b/flang/test/Semantics/procinterface02.f90
index 8b1becbe081e5..e5a99c14fbc46 100644
--- a/flang/test/Semantics/procinterface02.f90
+++ b/flang/test/Semantics/procinterface02.f90
@@ -12,7 +12,7 @@ real function foo_nonelemental(x)
     end function
   end interface
   real :: A(:), B(:)
-  !PORTABILITY: A dummy procedure should not have an ELEMENTAL intrinsic as its interface
+  !PORTABILITY: A dummy procedure should not have an ELEMENTAL intrinsic as its interface [-Wno-portability]
   procedure(sqrt), pointer :: P
   !ERROR: Rank of dummy argument is 0, but actual argument has rank 1
   A = P(B)
diff --git a/flang/test/Semantics/procinterface04.f90 b/flang/test/Semantics/procinterface04.f90
index f59e53f90dab1..d5b8a7371c02a 100644
--- a/flang/test/Semantics/procinterface04.f90
+++ b/flang/test/Semantics/procinterface04.f90
@@ -9,11 +9,11 @@ pure real function nonelemental(x)
       real, intent(in) :: x
     end
   end interface
-  !PORTABILITY: A dummy procedure should not have an ELEMENTAL intrinsic as its interface
+  !PORTABILITY: A dummy procedure should not have an ELEMENTAL intrinsic as its interface [-Wno-portability]
   procedure(sin) :: dp1
   !ERROR: A dummy procedure may not be ELEMENTAL
   procedure(elemental) :: dp2
-  !PORTABILITY: Procedure pointer 'pp1' should not have an ELEMENTAL intrinsic as its interface
+  !PORTABILITY: Procedure pointer 'pp1' should not have an ELEMENTAL intrinsic as its interface [-Wno-portability]
   procedure(sin), pointer :: pp1
   !ERROR: Procedure pointer 'pp2' may not be ELEMENTAL
   procedure(elemental), pointer :: pp2
diff --git a/flang/test/Semantics/resolve05.f90 b/flang/test/Semantics/resolve05.f90
index 4e50feb64e4c3..e88feae0dc364 100644
--- a/flang/test/Semantics/resolve05.f90
+++ b/flang/test/Semantics/resolve05.f90
@@ -1,18 +1,18 @@
 ! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
 program p
-  !PORTABILITY: Name 'p' declared in a main program should not have the same name as the main program
+  !PORTABILITY: Name 'p' declared in a main program should not have the same name as the main program [-Wno-benign-name-clash]
   integer :: p
 end
 module m
-  !PORTABILITY: Name 'm' declared in a module should not have the same name as the module
+  !PORTABILITY: Name 'm' declared in a module should not have the same name as the module [-Wno-benign-name-clash]
   integer :: m
 end
 submodule(m) sm
-  !PORTABILITY: Name 'sm' declared in a submodule should not have the same name as the submodule
+  !PORTABILITY: Name 'sm' declared in a submodule should not have the same name as the submodule [-Wno-benign-name-clash]
   integer :: sm
 end
 block data bd
-  !PORTABILITY: Name 'bd' declared in a BLOCK DATA subprogram should not have the same name as the BLOCK DATA subprogram
+  !PORTABILITY: Name 'bd' declared in a BLOCK DATA subprogram should not have the same name as the BLOCK DATA subprogram [-Wno-benign-name-clash]
   type bd
   end type
 end
diff --git a/flang/test/Semantics/resolve108.f90 b/flang/test/Semantics/resolve108.f90
index 644b8fba86892..8120b080f5986 100644
--- a/flang/test/Semantics/resolve108.f90
+++ b/flang/test/Semantics/resolve108.f90
@@ -44,7 +44,7 @@ subroutine s2
   use :: m2, only: foo
   !If we got the type of foo right, this declaration will fail
   !due to an attempted division by zero.
-  !WARNING: INTEGER(4) division by zero
+  !WARNING: INTEGER(4) division by zero [-Wno-folding-exception]
   !ERROR: Must be a constant value
   integer, parameter :: test = 1 / (kind(foo(1)) - kind(1.d0))
 end subroutine
@@ -54,7 +54,7 @@ module m3
  contains
   real(kind=kind(x)) function foo(x)
     real(kind=kind(1.0d0)) x
-    !WARNING: INTEGER(4) division by zero
+    !WARNING: INTEGER(4) division by zero [-Wno-folding-exception]
     !ERROR: Must be a constant value
     integer, parameter :: test = 1 / (kind(foo) - kind(1.d0))
     foo = n
diff --git a/flang/test/Semantics/resolve11.f90 b/flang/test/Semantics/resolve11.f90
index 9ae4f52c4fd54..c36a17f51d041 100644
--- a/flang/test/Semantics/resolve11.f90
+++ b/flang/test/Semantics/resolve11.f90
@@ -4,7 +4,7 @@ module m
   integer, private :: j
   !ERROR: The accessibility of 'i' has already been specified as PUBLIC
   private i
-  !WARNING: The accessibility of 'j' has already been specified as PRIVATE
+  !WARNING: The accessibility of 'j' has already been specified as PRIVATE [-Wno-redundant-attribute]
   private j
 end
 
@@ -66,7 +66,7 @@ subroutine s4
   !ERROR: 'fun' is PRIVATE in 'm4'
   use m4, only: foo, fun
   type(foo) x ! ok
-  !PORTABILITY: Reference to generic function 'foo' (resolving to specific 'fun') is ambiguous with a structure constructor of the same name
+  !PORTABILITY: Reference to generic function 'foo' (resolving to specific 'fun') is ambiguous with a structure constructor of the same name [-Wno-ambiguous-structure-constructor]
   print *, foo()
 end
 
diff --git a/flang/test/Semantics/resolve114.f90 b/flang/test/Semantics/resolve114.f90
index 6204e5fc2f3f4..7b46526f33821 100644
--- a/flang/test/Semantics/resolve114.f90
+++ b/flang/test/Semantics/resolve114.f90
@@ -34,9 +34,9 @@ end module m2
 subroutine s2a
   use m1
   use m2
-  !PORTABILITY: Procedure pointer 'p1' should not have an ELEMENTAL intrinsic as its interface
+  !PORTABILITY: Procedure pointer 'p1' should not have an ELEMENTAL intrinsic as its interface [-Wno-portability]
   procedure(sin), pointer :: p1 => sin
-  !PORTABILITY: Procedure pointer 'p2' should not have an ELEMENTAL intrinsic as its interface
+  !PORTABILITY: Procedure pointer 'p2' should not have an ELEMENTAL intrinsic as its interface [-Wno-portability]
   procedure(iabs), pointer :: p2 => iabs
   procedure(ext1), pointer :: p3 => ext1
   procedure(ext2), pointer :: p4 => ext2
@@ -46,9 +46,9 @@ subroutine s2b
   use m1, only: x1 => sin, x2 => iabs, x3 => ext1, x4 => ext2
   use m2, only: x1 => sin, x2 => iabs, x3 => ext1, x4 => ext2
   use m1, only: iface1 => sin, iface2 => iabs, iface3 => ext1, iface4 => ext2
-  !PORTABILITY: Procedure pointer 'p1' should not have an ELEMENTAL intrinsic as its interface
+  !PORTABILITY: Procedure pointer 'p1' should not have an ELEMENTAL intrinsic as its interface [-Wno-portability]
   procedure(iface1), pointer :: p1 => x1
-  !PORTABILITY: Procedure pointer 'p2' should not have an ELEMENTAL intrinsic as its interface
+  !PORTABILITY: Procedure pointer 'p2' should not have an ELEMENTAL intrinsic as its interface [-Wno-portability]
   procedure(iface2), pointer :: p2 => x2
   procedure(iface3), pointer :: p3 => x3
   procedure(iface4), pointer :: p4 => x4
@@ -60,9 +60,9 @@ module m3
 end module
 subroutine s3
   use m3
-  !PORTABILITY: Procedure pointer 'p1' should not have an ELEMENTAL intrinsic as its interface
+  !PORTABILITY: Procedure pointer 'p1' should not have an ELEMENTAL intrinsic as its interface [-Wno-portability]
   procedure(sin), pointer :: p1 => sin
-  !PORTABILITY: Procedure pointer 'p2' should not have an ELEMENTAL intrinsic as its interface
+  !PORTABILITY: Procedure pointer 'p2' should not have an ELEMENTAL intrinsic as its interface [-Wno-portability]
   procedure(iabs), pointer :: p2 => iabs
   procedure(ext1), pointer :: p3 => ext1
   procedure(ext2), pointer :: p4 => ext2
@@ -75,9 +75,9 @@ module m4
 subroutine s4
   use m4
   use m1, only: iface1 => sin, iface2 => iabs, iface3 => ext1, iface4 => ext2
-  !PORTABILITY: Procedure pointer 'p1' should not have an ELEMENTAL intrinsic as its interface
+  !PORTABILITY: Procedure pointer 'p1' should not have an ELEMENTAL intrinsic as its interface [-Wno-portability]
   procedure(iface1), pointer :: p1 => x1
-  !PORTABILITY: Procedure pointer 'p2' should not have an ELEMENTAL intrinsic as its interface
+  !PORTABILITY: Procedure pointer 'p2' should not have an ELEMENTAL intrinsic as its interface [-Wno-portability]
   procedure(iface2), pointer :: p2 => x2
   procedure(iface3), pointer :: p3 => x3
   procedure(iface4), pointer :: p4 => x4
@@ -87,10 +87,10 @@ subroutine s5
   use m1, only: x1 => sin, x2 => iabs, x3 => ext1, x4 => ext2
   use m2, only: x1 => tan, x2 => idim, x3 => ext2, x4 => ext1
   use m1, only: iface1 => sin, iface2 => iabs, iface3 => ext1, iface4 => ext2
-  !PORTABILITY: Procedure pointer 'p1' should not have an ELEMENTAL intrinsic as its interface
+  !PORTABILITY: Procedure pointer 'p1' should not have an ELEMENTAL intrinsic as its interface [-Wno-portability]
   !ERROR: Reference to 'x1' is ambiguous
   procedure(iface1), pointer :: p1 => x1
-  !PORTABILITY: Procedure pointer 'p2' should not have an ELEMENTAL intrinsic as its interface
+  !PORTABILITY: Procedure pointer 'p2' should not have an ELEMENTAL intrinsic as its interface [-Wno-portability]
   !ERROR: Reference to 'x2' is ambiguous
   procedure(iface2), pointer :: p2 => x2
   !ERROR: Reference to 'x3' is ambiguous
diff --git a/flang/test/Semantics/resolve118.f90 b/flang/test/Semantics/resolve118.f90
index 024b67b5a471b..c96144ccd2efb 100644
--- a/flang/test/Semantics/resolve118.f90
+++ b/flang/test/Semantics/resolve118.f90
@@ -17,7 +17,7 @@ module m3
   interface
     subroutine s1(x)
       use m1
-      !PORTABILITY: The same 't' is already present in this scope
+      !PORTABILITY: The same 't' is already present in this scope [-Wno-benign-name-clash]
       import t
       type(t) x
     end
diff --git a/flang/test/Semantics/resolve17.f90 b/flang/test/Semantics/resolve17.f90
index 6a6e355abe0b8..d785b58122b59 100644
--- a/flang/test/Semantics/resolve17.f90
+++ b/flang/test/Semantics/resolve17.f90
@@ -11,7 +11,7 @@ module m2
   interface s
   end interface
 contains
-  !WARNING: 's' should not be the name of both a generic interface and a procedure unless it is a specific procedure of the generic
+  !WARNING: 's' should not be the name of both a generic interface and a procedure unless it is a specific procedure of the generic [-Wno-homonymous-specific]
   subroutine s
   end subroutine
 end module
@@ -290,7 +290,7 @@ module m14d
  contains
   subroutine test
     real :: y
-    !PORTABILITY: Reference to generic function 'foo' (resolving to specific 'bar') is ambiguous with a structure constructor of the same name
+    !PORTABILITY: Reference to generic function 'foo' (resolving to specific 'bar') is ambiguous with a structure constructor of the same name [-Wno-ambiguous-structure-constructor]
     y = foo(1.0)
     x = foo(2)
   end subroutine
@@ -302,7 +302,7 @@ module m14e
  contains
   subroutine test
     real :: y
-    !PORTABILITY: Reference to generic function 'foo' (resolving to specific 'bar') is ambiguous with a structure constructor of the same name
+    !PORTABILITY: Reference to generic function 'foo' (resolving to specific 'bar') is ambiguous with a structure constructor of the same name [-Wno-ambiguous-structure-constructor]
     y = foo(1.0)
     x = foo(2)
   end subroutine
diff --git a/flang/test/Semantics/resolve18.f90 b/flang/test/Semantics/resolve18.f90
index 547db5e85714c..761ee06853ec0 100644
--- a/flang/test/Semantics/resolve18.f90
+++ b/flang/test/Semantics/resolve18.f90
@@ -11,7 +11,7 @@ subroutine foo(x)
 module m2
   use m1
   implicit none
-  !WARNING: 'foo' should not be the name of both a generic interface and a procedure unless it is a specific procedure of the generic
+  !WARNING: 'foo' should not be the name of both a generic interface and a procedure unless it is a specific procedure of the generic [-Wno-homonymous-specific]
   interface foo
     module procedure s
   end interface
@@ -22,14 +22,14 @@ subroutine s(i)
 end module
 
 subroutine foo
-  !PORTABILITY: 'foo' is use-associated into a subprogram of the same name
+  !PORTABILITY: 'foo' is use-associated into a subprogram of the same name [-Wno-use-association-into-same-name-subprogram]
   use m1
   !ERROR: Reference to 'foo' is ambiguous
   call foo
 end
 
 subroutine bar
-  !PORTABILITY: 'foo' is use-associated into a subprogram of the same name
+  !PORTABILITY: 'foo' is use-associated into a subprogram of the same name [-Wno-use-association-into-same-name-subprogram]
   use m1, bar => foo
   !ERROR: Reference to 'bar' is ambiguous
   call bar
@@ -348,7 +348,7 @@ subroutine s_21_23
   use m21
   use m23
   type(foo) x ! Intel and NAG error
-  !PORTABILITY: Reference to generic function 'foo' (resolving to specific 'f1') is ambiguous with a structure constructor of the same name
+  !PORTABILITY: Reference to generic function 'foo' (resolving to specific 'f1') is ambiguous with a structure constructor of the same name [-Wno-ambiguous-structure-constructor]
   print *, foo(1.) ! Intel error
   print *, foo(1.,2.,3.) ! Intel error
   call ext(foo) ! GNU and Intel error
diff --git a/flang/test/Semantics/resolve20.f90 b/flang/test/Semantics/resolve20.f90
index 359bc0c1f9a3f..a5b65e3b77a9f 100644
--- a/flang/test/Semantics/resolve20.f90
+++ b/flang/test/Semantics/resolve20.f90
@@ -38,7 +38,7 @@ subroutine forward
   type :: bad3
   end type
 
-  !PORTABILITY: Name 'm' declared in a module should not have the same name as the module
+  !PORTABILITY: Name 'm' declared in a module should not have the same name as the module [-Wno-benign-name-clash]
   type :: m
   end type m
 
@@ -49,7 +49,7 @@ subroutine forward
   external :: a, b, c, d
   !ERROR: EXTERNAL attribute not allowed on 'm'
   external :: m
-  !WARNING: EXTERNAL attribute was already specified on 'foo'
+  !WARNING: EXTERNAL attribute was already specified on 'foo' [-Wno-redundant-attribute]
   external :: foo
   !ERROR: EXTERNAL attribute not allowed on 'bar'
   external :: bar
diff --git a/flang/test/Semantics/resolve24.f90 b/flang/test/Semantics/resolve24.f90
index 72d6719665bb5..5de0f8f6e1196 100644
--- a/flang/test/Semantics/resolve24.f90
+++ b/flang/test/Semantics/resolve24.f90
@@ -1,6 +1,6 @@
 ! RUN: %python %S/test_errors.py %s %flang_fc1
 subroutine test1
-  !WARNING: Generic interface 'foo' has both a function and a subroutine
+  !WARNING: Generic interface 'foo' has both a function and a subroutine [-Wno-subroutine-and-function-specifics]
   interface foo
     subroutine s1(x)
     end subroutine
@@ -12,7 +12,7 @@ function f()
 end subroutine
 
 subroutine test2
-  !WARNING: Generic interface 'foo' has both a function and a subroutine
+  !WARNING: Generic interface 'foo' has both a function and a subroutine [-Wno-subroutine-and-function-specifics]
   interface foo
     function t2f1(x)
     end function
@@ -24,7 +24,7 @@ function t2f2(x, y)
 end subroutine
 
 module test3
-  !WARNING: Generic interface 'foo' has both a function and a subroutine
+  !WARNING: Generic interface 'foo' has both a function and a subroutine [-Wno-subroutine-and-function-specifics]
   interface foo
     module procedure s
     module procedure f
@@ -39,7 +39,7 @@ function f()
 subroutine test4
   type foo
   end type
-  !WARNING: Generic interface 'foo' should only contain functions due to derived type with same name
+  !WARNING: Generic interface 'foo' should only contain functions due to derived type with same name [-Wno-subroutine-and-function-specifics]
   interface foo
     subroutine s()
     end subroutine
diff --git a/flang/test/Semantics/resolve30.f90 b/flang/test/Semantics/resolve30.f90
index 32108e89cdefe..f33871776e6d1 100644
--- a/flang/test/Semantics/resolve30.f90
+++ b/flang/test/Semantics/resolve30.f90
@@ -41,6 +41,6 @@ subroutine s4
 subroutine s5
   implicit none
   data x/1./
-  !PORTABILITY: 'x' appeared in a DATA statement before its type was declared under IMPLICIT NONE(TYPE)
+  !PORTABILITY: 'x' appeared in a DATA statement before its type was declared under IMPLICIT NONE(TYPE) [-Wno-forward-ref-implicit-none-data]
   real x
 end
diff --git a/flang/test/Semantics/resolve31.f90 b/flang/test/Semantics/resolve31.f90
index 6bf8e877a5156..08d210c138619 100644
--- a/flang/test/Semantics/resolve31.f90
+++ b/flang/test/Semantics/resolve31.f90
@@ -49,9 +49,9 @@ module m4
   type :: t1
     private
     sequence
-    !WARNING: PRIVATE should not appear more than once in derived type components
+    !WARNING: PRIVATE should not appear more than once in derived type components [-Wno-redundant-attribute]
     private
-    !WARNING: SEQUENCE should not appear more than once in derived type components
+    !WARNING: SEQUENCE should not appear more than once in derived type components [-Wno-redundant-attribute]
     sequence
     real :: t1Field
   end type
@@ -68,7 +68,7 @@ module m4
   !ERROR: A sequence type may not have a CONTAINS statement
   contains
   end type
-  !WARNING: A sequence type should have at least one component
+  !WARNING: A sequence type should have at least one component [-Wno-empty-sequence-type]
   type :: emptyType
     sequence
   end type emptyType
@@ -85,7 +85,7 @@ module m4
     class(*), allocatable :: typeStarField
     !ERROR: A sequence type data component must either be of an intrinsic type or a derived sequence type
     type(plainType) :: testField1
-    !WARNING: A sequence type data component that is a pointer to a non-sequence type is not standard
+    !WARNING: A sequence type data component that is a pointer to a non-sequence type is not standard [-Wno-pointer-in-seq-type]
     type(plainType), pointer :: testField1p
     type(sequenceType) :: testField2
     procedure(real), pointer, nopass :: procField
diff --git a/flang/test/Semantics/resolve35.f90 b/flang/test/Semantics/resolve35.f90
index 2947b225978d1..9f9ecb73084b9 100644
--- a/flang/test/Semantics/resolve35.f90
+++ b/flang/test/Semantics/resolve35.f90
@@ -21,14 +21,14 @@ subroutine s3
   real :: a(10,10), b(10,10)
   type y; end type
   integer(8) :: x
-  !PORTABILITY: Index variable 'y' should be a scalar object or common block if it is present in the enclosing scope
+  !PORTABILITY: Index variable 'y' should be a scalar object or common block if it is present in the enclosing scope [-Wno-odd-index-variable-restrictions]
   !ERROR: Must have INTEGER type, but is REAL(4)
   forall(x=1:10, y=1:10)
     !ERROR: Must have INTEGER type, but is REAL(4)
     !ERROR: Must have INTEGER type, but is REAL(4)
     a(x, y) = b(x, y)
   end forall
-  !PORTABILITY: Index variable 'y' should be a scalar object or common block if it is present in the enclosing scope
+  !PORTABILITY: Index variable 'y' should be a scalar object or common block if it is present in the enclosing scope [-Wno-odd-index-variable-restrictions]
   !ERROR: Must have INTEGER type, but is REAL(4)
   !ERROR: Must have INTEGER type, but is REAL(4)
   !ERROR: Must have INTEGER type, but is REAL(4)
@@ -51,7 +51,7 @@ subroutine s4
     !ERROR: Must have INTEGER type, but is REAL(4)
     a(y) = b(y)
   end forall
-  !PORTABILITY: Index variable 'i' should be scalar in the enclosing scope
+  !PORTABILITY: Index variable 'i' should be scalar in the enclosing scope [-Wno-odd-index-variable-restrictions]
   forall(i=1:10)
     a(i) = b(i)
   end forall
@@ -61,7 +61,7 @@ subroutine s6
   integer, parameter :: n = 4
   real, dimension(n) :: x
   data(x(i), i=1, n) / n * 0.0 /
-  !PORTABILITY: Index variable 't' should be a scalar object or common block if it is present in the enclosing scope
+  !PORTABILITY: Index variable 't' should be a scalar object or common block if it is present in the enclosing scope [-Wno-odd-index-variable-restrictions]
   !ERROR: Must have INTEGER type, but is REAL(4)
   !ERROR: Must have INTEGER type, but is REAL(4)
   forall(t=1:n) x(t) = 0.0
@@ -86,7 +86,7 @@ subroutine s7
   do concurrent(integer::i=1:5) local(j, i) &
       !ERROR: 'j' is already declared in this scoping unit
       local_init(k, j) &
-      !WARNING: Variable 'a' with SHARED locality implicitly declared
+      !WARNING: Variable 'a' with SHARED locality implicitly declared [-Wno-implicit-shared]
       shared(a)
     a = j + 1
   end do
diff --git a/flang/test/Semantics/resolve37.f90 b/flang/test/Semantics/resolve37.f90
index f8229f1f974a4..55630ebb4b408 100644
--- a/flang/test/Semantics/resolve37.f90
+++ b/flang/test/Semantics/resolve37.f90
@@ -25,25 +25,25 @@
 character(len=l) :: v
 !ERROR: Value of named constant 'o' (o) cannot be computed as a constant value
 real, parameter ::  o = o
-!WARNING: INTEGER(4) division by zero
+!WARNING: INTEGER(4) division by zero [-Wno-folding-exception]
 !ERROR: Must be a constant value
 integer, parameter ::  p = 0/0
-!WARNING: INTEGER(4) division by zero
+!WARNING: INTEGER(4) division by zero [-Wno-folding-exception]
 !ERROR: Must be a constant value
-!WARNING: INTEGER(4) division by zero
-!WARNING: INTEGER(4) division by zero
-!WARNING: INTEGER(4) division by zero
+!WARNING: INTEGER(4) division by zero [-Wno-folding-exception]
+!WARNING: INTEGER(4) division by zero [-Wno-folding-exception]
+!WARNING: INTEGER(4) division by zero [-Wno-folding-exception]
 integer, parameter ::  q = 1+2*(1/0)
 integer not_constant
 !ERROR: Must be a constant value
 integer, parameter :: s1 = not_constant/2
 !ERROR: Must be a constant value
 integer, parameter :: s2 = 3/not_constant
-!WARNING: INTEGER(4) division by zero
+!WARNING: INTEGER(4) division by zero [-Wno-folding-exception]
 !ERROR: Must be a constant value
 integer(kind=2/0) r
 integer, parameter :: sok(*)=[1,2]/[1,2]
-!WARNING: INTEGER(4) division by zero
+!WARNING: INTEGER(4) division by zero [-Wno-folding-exception]
 !ERROR: Must be a constant value
 integer, parameter :: snok(*)=[1,2]/[1,0]
 end
diff --git a/flang/test/Semantics/resolve45.f90 b/flang/test/Semantics/resolve45.f90
index 7f6d8d6ae50b2..ee818ade26e5c 100644
--- a/flang/test/Semantics/resolve45.f90
+++ b/flang/test/Semantics/resolve45.f90
@@ -36,13 +36,13 @@ subroutine s3(x)
 end
 
 subroutine s4
-  !WARNING: Explicit SAVE of 'z' is redundant due to global SAVE statement
+  !WARNING: Explicit SAVE of 'z' is redundant due to global SAVE statement [-Wno-redundant-attribute]
   save z
   save
   procedure(integer), pointer :: x
-  !WARNING: Explicit SAVE of 'x' is redundant due to global SAVE statement
+  !WARNING: Explicit SAVE of 'x' is redundant due to global SAVE statement [-Wno-redundant-attribute]
   save :: x
-  !WARNING: Explicit SAVE of 'y' is redundant due to global SAVE statement
+  !WARNING: Explicit SAVE of 'y' is redundant due to global SAVE statement [-Wno-redundant-attribute]
   integer, save :: y
 end
 
diff --git a/flang/test/Semantics/resolve46.f90 b/flang/test/Semantics/resolve46.f90
index 0acc20b19f0b7..8b7f941cda6cd 100644
--- a/flang/test/Semantics/resolve46.f90
+++ b/flang/test/Semantics/resolve46.f90
@@ -20,7 +20,7 @@ logical function chrcmp(a,b)
      end function chrcmp
   end interface
 
-  !PORTABILITY: Procedure pointer 'p' should not have an ELEMENTAL intrinsic as its interface
+  !PORTABILITY: Procedure pointer 'p' should not have an ELEMENTAL intrinsic as its interface [-Wno-portability]
   procedure(sin), pointer :: p => cos
   !ERROR: Intrinsic procedure 'amin0' is not an unrestricted specific intrinsic permitted for use as the definition of the interface to procedure pointer 'q'
   procedure(amin0), pointer :: q
@@ -29,7 +29,7 @@ end function chrcmp
   !ERROR: Intrinsic procedure 'llt' is not an unrestricted specific intrinsic permitted for use as the initializer for procedure pointer 's'
   procedure(chrcmp), pointer :: s => llt
   !ERROR: Intrinsic procedure 'bessel_j0' is not an unrestricted specific intrinsic permitted for use as the initializer for procedure pointer 't'
-  !PORTABILITY: Procedure pointer 't' should not have an ELEMENTAL intrinsic as its interface
+  !PORTABILITY: Procedure pointer 't' should not have an ELEMENTAL intrinsic as its interface [-Wno-portability]
   procedure(cos), pointer :: t => bessel_j0
   procedure(chrcmp), pointer :: u
   p => alog ! valid use of an unrestricted specific intrinsic
diff --git a/flang/test/Semantics/resolve58.f90 b/flang/test/Semantics/resolve58.f90
index 7686de4898404..9fcce2ba0b350 100644
--- a/flang/test/Semantics/resolve58.f90
+++ b/flang/test/Semantics/resolve58.f90
@@ -69,12 +69,12 @@ subroutine s6()
 
   !ERROR: Implied-shape array 'local1' must be a named constant or a dummy argument
   real, dimension (*) :: local1
-  !WARNING: Only a dummy argument should have an INTENT, VALUE, or OPTIONAL attribute
+  !WARNING: Only a dummy argument should have an INTENT, VALUE, or OPTIONAL attribute [-Wno-ignore-irrelevant-attributes]
   real, intent(in) :: local2
-  !WARNING: Only a dummy argument should have an INTENT, VALUE, or OPTIONAL attribute
+  !WARNING: Only a dummy argument should have an INTENT, VALUE, or OPTIONAL attribute [-Wno-ignore-irrelevant-attributes]
   procedure(), intent(in) :: p1
-  !WARNING: Only a dummy argument should have an INTENT, VALUE, or OPTIONAL attribute
+  !WARNING: Only a dummy argument should have an INTENT, VALUE, or OPTIONAL attribute [-Wno-ignore-irrelevant-attributes]
   real, optional :: local3
-  !WARNING: Only a dummy argument should have an INTENT, VALUE, or OPTIONAL attribute
+  !WARNING: Only a dummy argument should have an INTENT, VALUE, or OPTIONAL attribute [-Wno-ignore-irrelevant-attributes]
   procedure(), optional :: p2
 end subroutine
diff --git a/flang/test/Semantics/resolve59.f90 b/flang/test/Semantics/resolve59.f90
index 3bdcf67aa958a..ef6db06440d47 100644
--- a/flang/test/Semantics/resolve59.f90
+++ b/flang/test/Semantics/resolve59.f90
@@ -59,10 +59,10 @@ real function rfunc(x)
     x = acos(f5)
   end function
   ! Sanity test: f18 handles C1560 violation by ignoring RESULT
-  !WARNING: The function name should not appear in RESULT; references to 'f6' inside the function will be considered as references to the result only
+  !WARNING: The function name should not appear in RESULT; references to 'f6' inside the function will be considered as references to the result only [-Wno-homonymous-result]
   function f6() result(f6)
   end function
-  !WARNING: The function name should not appear in RESULT; references to 'f7' inside the function will be considered as references to the result only
+  !WARNING: The function name should not appear in RESULT; references to 'f7' inside the function will be considered as references to the result only [-Wno-homonymous-result]
   function f7() result(f7)
     real :: x, f7
     !ERROR: Recursive call to 'f7' requires a distinct RESULT in its declaration
@@ -114,7 +114,7 @@ function f4() result(r)
   end function
   function f5(x) result(r)
     real :: x
-    !PORTABILITY: Procedure pointer 'r' should not have an ELEMENTAL intrinsic as its interface
+    !PORTABILITY: Procedure pointer 'r' should not have an ELEMENTAL intrinsic as its interface [-Wno-portability]
     procedure(acos), pointer :: r
     r => acos
     !ERROR: Actual argument for 'x=' may not be a procedure
diff --git a/flang/test/Semantics/resolve60.f90 b/flang/test/Semantics/resolve60.f90
index ff988d54a8210..4557eb4db96c9 100644
--- a/flang/test/Semantics/resolve60.f90
+++ b/flang/test/Semantics/resolve60.f90
@@ -32,7 +32,7 @@
 
   enum, bind(C)
     !ERROR: Enumerator value could not be computed from the given expression
-    !WARNING: INTEGER(4) division by zero
+    !WARNING: INTEGER(4) division by zero [-Wno-folding-exception]
     !ERROR: Must be a constant value
     enumerator :: wrong = 0/0
   end enum
diff --git a/flang/test/Semantics/resolve61.f90 b/flang/test/Semantics/resolve61.f90
index 2a1f584ffaf08..ee14fc50a26e5 100644
--- a/flang/test/Semantics/resolve61.f90
+++ b/flang/test/Semantics/resolve61.f90
@@ -114,7 +114,7 @@ subroutine p12
   type(t2) :: x2
   type(t3) :: x3
   pointer(a, x1)
-  !WARNING: Type of Cray pointee 'x2' is a derived type that is neither SEQUENCE nor BIND(C)
+  !WARNING: Type of Cray pointee 'x2' is a derived type that is neither SEQUENCE nor BIND(C) [-Wno-non-sequence-cray-pointee]
   pointer(b, x2)
   pointer(c, x3)
 end
diff --git a/flang/test/Semantics/resolve65.f90 b/flang/test/Semantics/resolve65.f90
index b2815c4ed1c79..ba0c4e2f1df3b 100644
--- a/flang/test/Semantics/resolve65.f90
+++ b/flang/test/Semantics/resolve65.f90
@@ -15,8 +15,8 @@ module m1
     procedure :: assign_t2
     procedure :: assign_t3
     !ERROR: Defined assignment subroutine 'assign_t2' must have two dummy arguments
-    !WARNING: In defined assignment subroutine 'assign_t3', second dummy argument 'y' should have INTENT(IN) or VALUE attribute
-    !WARNING: In defined assignment subroutine 'assign_t4', first dummy argument 'x' should have INTENT(OUT) or INTENT(INOUT)
+    !WARNING: In defined assignment subroutine 'assign_t3', second dummy argument 'y' should have INTENT(IN) or VALUE attribute [-Wno-defined-operator-args]
+    !WARNING: In defined assignment subroutine 'assign_t4', first dummy argument 'x' should have INTENT(OUT) or INTENT(INOUT) [-Wno-defined-operator-args]
     !ERROR: In defined assignment subroutine 'assign_t5', first dummy argument 'x' may not have INTENT(IN)
     !ERROR: In defined assignment subroutine 'assign_t6', second dummy argument 'y' may not have INTENT(OUT)
     generic :: assignment(=) => assign_t, assign_t2, assign_t3, assign_t4, assign_t5, assign_t6
diff --git a/flang/test/Semantics/resolve67.f90 b/flang/test/Semantics/resolve67.f90
index 677eef21d0a8f..79ff4162eaf4b 100644
--- a/flang/test/Semantics/resolve67.f90
+++ b/flang/test/Semantics/resolve67.f90
@@ -41,7 +41,7 @@ character(*) function divide(x, y)
     end
   end interface
   interface operator(<)
-    !WARNING: In OPERATOR(<) function 'lt1', dummy argument 'x' should have INTENT(IN) or VALUE attribute
+    !WARNING: In OPERATOR(<) function 'lt1', dummy argument 'x' should have INTENT(IN) or VALUE attribute [-Wno-defined-operator-args]
     !ERROR: In OPERATOR(<) function 'lt1', dummy argument 'y' may not be OPTIONAL
     logical function lt1(x, y)
       logical :: x
@@ -90,7 +90,7 @@ real function plus(x)
     end
   end interface
   interface operator(.not.)
-    !WARNING: The external interface 'not1' is not compatible with an earlier definition (distinct numbers of dummy arguments)
+    !WARNING: The external interface 'not1' is not compatible with an earlier definition (distinct numbers of dummy arguments) [-Wno-external-interface-mismatch]
     real function not1(x)
       real, value :: x
     end
diff --git a/flang/test/Semantics/resolve69.f90 b/flang/test/Semantics/resolve69.f90
index 5acfd30604fe3..02c93245c559b 100644
--- a/flang/test/Semantics/resolve69.f90
+++ b/flang/test/Semantics/resolve69.f90
@@ -16,7 +16,7 @@ subroutine s1()
   !
   integer, parameter :: constVal = 1
   integer :: nonConstVal = 1
-!PORTABILITY: specification expression refers to local object 'nonconstval' (initialized and saved)
+!PORTABILITY: specification expression refers to local object 'nonconstval' (initialized and saved) [-Wno-saved-local-in-spec-expr]
   character(nonConstVal) :: colonString1
   character(len=20, kind=constVal + 1) :: constKindString
   character(len=:, kind=constVal + 1), pointer :: constKindString1
@@ -53,13 +53,13 @@ function foo3()
 
   type (derived(constVal, 3)) :: constDerivedKind
 !ERROR: Value of KIND type parameter 'typekind' must be constant
-!PORTABILITY: specification expression refers to local object 'nonconstval' (initialized and saved)
+!PORTABILITY: specification expression refers to local object 'nonconstval' (initialized and saved) [-Wno-saved-local-in-spec-expr]
   type (derived(nonConstVal, 3)) :: nonConstDerivedKind
 
   !OK because all type-params are constants
   type (derived(3, constVal)) :: constDerivedLen
 
-!PORTABILITY: specification expression refers to local object 'nonconstval' (initialized and saved)
+!PORTABILITY: specification expression refers to local object 'nonconstval' (initialized and saved) [-Wno-saved-local-in-spec-expr]
   type (derived(3, nonConstVal)) :: nonConstDerivedLen
 !ERROR: 'colonderivedlen' has a type derived(typekind=3_4,typelen=:) with a deferred type parameter but is neither an allocatable nor an object pointer
   type (derived(3, :)) :: colonDerivedLen
diff --git a/flang/test/Semantics/resolve77.f90 b/flang/test/Semantics/resolve77.f90
index 0133fac3bfbc5..a0cecbc34fff2 100644
--- a/flang/test/Semantics/resolve77.f90
+++ b/flang/test/Semantics/resolve77.f90
@@ -60,13 +60,13 @@ pure integer function if2(n)
 block data
   common /blk2/ n
   data n/100/
-  !PORTABILITY: specification expression refers to local object 'n' (initialized and saved)
+  !PORTABILITY: specification expression refers to local object 'n' (initialized and saved) [-Wno-saved-local-in-spec-expr]
   !ERROR: Automatic data object 'a' may not appear in a BLOCK DATA subprogram
   real a(n)
 end
 
 program main
   common /blk2/ n
-  !PORTABILITY: Automatic data object 'a' should not appear in the specification part of a main program
+  !PORTABILITY: Automatic data object 'a' should not appear in the specification part of a main program [-Wno-automatic-in-main-program]
   real a(n)
 end
diff --git a/flang/test/Semantics/resolve78.f90 b/flang/test/Semantics/resolve78.f90
index 8c25f32e80cdc..57d58a4ef6055 100644
--- a/flang/test/Semantics/resolve78.f90
+++ b/flang/test/Semantics/resolve78.f90
@@ -11,21 +11,21 @@ module m
 !      POINTER
 
   type :: derived
-    !WARNING: Attribute 'PUBLIC' cannot be used more than once
+    !WARNING: Attribute 'PUBLIC' cannot be used more than once [-Wno-redundant-attribute]
     real, public, allocatable, public :: field1
-    !WARNING: Attribute 'PRIVATE' cannot be used more than once
+    !WARNING: Attribute 'PRIVATE' cannot be used more than once [-Wno-redundant-attribute]
     real, private, allocatable, private :: field2
     !ERROR: Attributes 'PUBLIC' and 'PRIVATE' conflict with each other
     real, public, allocatable, private :: field3
-    !WARNING: Attribute 'ALLOCATABLE' cannot be used more than once
+    !WARNING: Attribute 'ALLOCATABLE' cannot be used more than once [-Wno-redundant-attribute]
     real, allocatable, public, allocatable :: field4
     !ERROR: Attribute 'CODIMENSION' cannot be used more than once
     real, public, codimension[:], allocatable, codimension[:] :: field5
-    !WARNING: Attribute 'CONTIGUOUS' cannot be used more than once
+    !WARNING: Attribute 'CONTIGUOUS' cannot be used more than once [-Wno-redundant-attribute]
     real, public, contiguous, pointer, contiguous, dimension(:) :: field6
     !ERROR: Attribute 'DIMENSION' cannot be used more than once
     real, dimension(5), public, dimension(5) :: field7
-    !WARNING: Attribute 'POINTER' cannot be used more than once
+    !WARNING: Attribute 'POINTER' cannot be used more than once [-Wno-redundant-attribute]
     real, pointer, public, pointer :: field8
   end type derived
 
diff --git a/flang/test/Semantics/resolve79.f90 b/flang/test/Semantics/resolve79.f90
index 037e107dc5874..b0d48fbf63789 100644
--- a/flang/test/Semantics/resolve79.f90
+++ b/flang/test/Semantics/resolve79.f90
@@ -12,17 +12,17 @@ module m
 !    PUBLIC, PRIVATE, NOPASS, PASS, POINTER
 
   type :: procComponentType
-    !WARNING: Attribute 'PUBLIC' cannot be used more than once
+    !WARNING: Attribute 'PUBLIC' cannot be used more than once [-Wno-redundant-attribute]
     procedure(publicProc), public, pointer, public :: publicField
-    !WARNING: Attribute 'PRIVATE' cannot be used more than once
+    !WARNING: Attribute 'PRIVATE' cannot be used more than once [-Wno-redundant-attribute]
     procedure(privateProc), private, pointer, private :: privateField
-    !WARNING: Attribute 'NOPASS' cannot be used more than once
+    !WARNING: Attribute 'NOPASS' cannot be used more than once [-Wno-redundant-attribute]
     procedure(nopassProc), nopass, pointer, nopass :: noPassField
-    !WARNING: Attribute 'PASS' cannot be used more than once
+    !WARNING: Attribute 'PASS' cannot be used more than once [-Wno-redundant-attribute]
     procedure(passProc), pass, pointer, pass :: passField
     !ERROR: Attributes 'PASS' and 'NOPASS' conflict with each other
     procedure(passNopassProc), pass, pointer, nopass :: passNopassField
-    !WARNING: Attribute 'POINTER' cannot be used more than once
+    !WARNING: Attribute 'POINTER' cannot be used more than once [-Wno-redundant-attribute]
     procedure(pointerProc), pointer, public, pointer :: pointerField
     !ERROR: Procedure component 'nonpointerfield' must have POINTER attribute
     procedure(publicProc), public :: nonpointerField
diff --git a/flang/test/Semantics/resolve80.f90 b/flang/test/Semantics/resolve80.f90
index e787a4ba7f866..eb10af9741f43 100644
--- a/flang/test/Semantics/resolve80.f90
+++ b/flang/test/Semantics/resolve80.f90
@@ -13,17 +13,17 @@ module m
 !
   type, abstract :: boundProcType
    contains
-    !WARNING: Attribute 'PUBLIC' cannot be used more than once
+    !WARNING: Attribute 'PUBLIC' cannot be used more than once [-Wno-redundant-attribute]
     procedure(subPublic), public, deferred, public :: publicBinding
-    !WARNING: Attribute 'PRIVATE' cannot be used more than once
+    !WARNING: Attribute 'PRIVATE' cannot be used more than once [-Wno-redundant-attribute]
     procedure(subPrivate), private, deferred, private :: privateBinding
-    !WARNING: Attribute 'DEFERRED' cannot be used more than once
+    !WARNING: Attribute 'DEFERRED' cannot be used more than once [-Wno-redundant-attribute]
     procedure(subDeferred), deferred, public, deferred :: deferredBinding
-    !WARNING: Attribute 'NON_OVERRIDABLE' cannot be used more than once
+    !WARNING: Attribute 'NON_OVERRIDABLE' cannot be used more than once [-Wno-redundant-attribute]
     procedure, non_overridable, public, non_overridable :: subNon_overridable;
-    !WARNING: Attribute 'NOPASS' cannot be used more than once
+    !WARNING: Attribute 'NOPASS' cannot be used more than once [-Wno-redundant-attribute]
     procedure(subNopass), nopass, deferred, nopass :: nopassBinding
-    !WARNING: Attribute 'PASS' cannot be used more than once
+    !WARNING: Attribute 'PASS' cannot be used more than once [-Wno-redundant-attribute]
     procedure(subPass), pass, deferred, pass :: passBinding
     !ERROR: Attributes 'PASS' and 'NOPASS' conflict with each other
     procedure(subPassNopass), pass, deferred, nopass :: passNopassBinding  ! C781
diff --git a/flang/test/Semantics/resolve81.f90 b/flang/test/Semantics/resolve81.f90
index db5b19f1155ea..ed5b6c2d36dcb 100644
--- a/flang/test/Semantics/resolve81.f90
+++ b/flang/test/Semantics/resolve81.f90
@@ -11,52 +11,52 @@
 !    VOLATILE
 module m
 
-  !WARNING: Attribute 'PUBLIC' cannot be used more than once
+  !WARNING: Attribute 'PUBLIC' cannot be used more than once [-Wno-redundant-attribute]
   real, public, allocatable, public :: publicVar
-  !WARNING: Attribute 'PRIVATE' cannot be used more than once
+  !WARNING: Attribute 'PRIVATE' cannot be used more than once [-Wno-redundant-attribute]
   real, private, allocatable, private :: privateVar
-  !WARNING: Attribute 'ALLOCATABLE' cannot be used more than once
+  !WARNING: Attribute 'ALLOCATABLE' cannot be used more than once [-Wno-redundant-attribute]
   real, allocatable, allocatable :: allocVar
-  !WARNING: Attribute 'ASYNCHRONOUS' cannot be used more than once
+  !WARNING: Attribute 'ASYNCHRONOUS' cannot be used more than once [-Wno-redundant-attribute]
   real, asynchronous, public, asynchronous :: asynchVar
   !ERROR: Attribute 'CODIMENSION' cannot be used more than once
   real, codimension[*], codimension[*] :: codimensionVar
-  !WARNING: Attribute 'CONTIGUOUS' cannot be used more than once
+  !WARNING: Attribute 'CONTIGUOUS' cannot be used more than once [-Wno-redundant-attribute]
   real, contiguous, pointer, contiguous :: contigVar(:)
   !ERROR: Attribute 'DIMENSION' cannot be used more than once
   real, dimension(5), dimension(5) :: arrayVar
-  !WARNING: Attribute 'EXTERNAL' cannot be used more than once
+  !WARNING: Attribute 'EXTERNAL' cannot be used more than once [-Wno-redundant-attribute]
   real, external, external :: externFunc
-  !WARNING: Attribute 'INTRINSIC' cannot be used more than once
+  !WARNING: Attribute 'INTRINSIC' cannot be used more than once [-Wno-redundant-attribute]
   !ERROR: 'cos' may not have both the BIND(C) and INTRINSIC attributes
   !ERROR: An interface name with the BIND attribute must appear if the BIND attribute appears in a procedure declaration
   real, intrinsic, bind(c), intrinsic :: cos
-  !WARNING: Attribute 'BIND(C)' cannot be used more than once
+  !WARNING: Attribute 'BIND(C)' cannot be used more than once [-Wno-redundant-attribute]
   integer, bind(c), volatile, bind(c) :: bindVar
-  !WARNING: Attribute 'PARAMETER' cannot be used more than once
+  !WARNING: Attribute 'PARAMETER' cannot be used more than once [-Wno-redundant-attribute]
   real, parameter, parameter :: realConst = 4.3
-  !WARNING: Attribute 'POINTER' cannot be used more than once
+  !WARNING: Attribute 'POINTER' cannot be used more than once [-Wno-redundant-attribute]
   real, pointer, pointer :: realPtr
-  !WARNING: Attribute 'PROTECTED' cannot be used more than once
+  !WARNING: Attribute 'PROTECTED' cannot be used more than once [-Wno-redundant-attribute]
   real, protected, protected :: realProt
-  !WARNING: Attribute 'SAVE' cannot be used more than once
+  !WARNING: Attribute 'SAVE' cannot be used more than once [-Wno-redundant-attribute]
   real, save, save :: saveVar
-  !WARNING: Attribute 'TARGET' cannot be used more than once
+  !WARNING: Attribute 'TARGET' cannot be used more than once [-Wno-redundant-attribute]
   real, target, target :: targetVar
-  !WARNING: Attribute 'VOLATILE' cannot be used more than once
+  !WARNING: Attribute 'VOLATILE' cannot be used more than once [-Wno-redundant-attribute]
   real, volatile, volatile :: volatileVar
 
 contains
     subroutine testTypeDecl(arg1, arg2, arg3, arg4, arg5, arg6)
-      !WARNING: Attribute 'INTENT(IN)' cannot be used more than once
+      !WARNING: Attribute 'INTENT(IN)' cannot be used more than once [-Wno-redundant-attribute]
       real, intent(in), intent(in) :: arg1
-      !WARNING: Attribute 'INTENT(OUT)' cannot be used more than once
+      !WARNING: Attribute 'INTENT(OUT)' cannot be used more than once [-Wno-redundant-attribute]
       real, intent(out), intent(out) :: arg2
-      !WARNING: Attribute 'INTENT(INOUT)' cannot be used more than once
+      !WARNING: Attribute 'INTENT(INOUT)' cannot be used more than once [-Wno-redundant-attribute]
       real, intent(inout), intent(inout) :: arg3
-      !WARNING: Attribute 'OPTIONAL' cannot be used more than once
+      !WARNING: Attribute 'OPTIONAL' cannot be used more than once [-Wno-redundant-attribute]
       integer, optional, intent(in), optional :: arg4
-      !WARNING: Attribute 'VALUE' cannot be used more than once
+      !WARNING: Attribute 'VALUE' cannot be used more than once [-Wno-redundant-attribute]
       integer, value, intent(in), value :: arg5
       !ERROR: Attributes 'INTENT(IN)' and 'INTENT(INOUT)' conflict with each other
       integer, intent(in), pointer, intent(inout) :: arg6
diff --git a/flang/test/Semantics/resolve82.f90 b/flang/test/Semantics/resolve82.f90
index 989ce1d837c70..2e66403386e7b 100644
--- a/flang/test/Semantics/resolve82.f90
+++ b/flang/test/Semantics/resolve82.f90
@@ -14,14 +14,14 @@ real function procFunc()
     end function procFunc
   end interface
 
-  !WARNING: Attribute 'PUBLIC' cannot be used more than once
+  !WARNING: Attribute 'PUBLIC' cannot be used more than once [-Wno-redundant-attribute]
   procedure(procFunc), public, pointer, public :: proc1
-  !WARNING: Attribute 'PRIVATE' cannot be used more than once
+  !WARNING: Attribute 'PRIVATE' cannot be used more than once [-Wno-redundant-attribute]
   procedure(procFunc), private, pointer, private :: proc2
-  !WARNING: Attribute 'BIND(C)' cannot be used more than once
+  !WARNING: Attribute 'BIND(C)' cannot be used more than once [-Wno-redundant-attribute]
   !ERROR: An interface name with the BIND attribute must appear if the BIND attribute appears in a procedure declaration
   procedure(procFunc), bind(c), pointer, bind(c) :: proc3
-  !WARNING: Attribute 'PROTECTED' cannot be used more than once
+  !WARNING: Attribute 'PROTECTED' cannot be used more than once [-Wno-redundant-attribute]
   procedure(procFunc), protected, pointer, protected :: proc4
   !ERROR: A PROTECTED entity must be a variable or pointer
   external extsub
@@ -39,21 +39,21 @@ end function procFunc
 contains
 
     subroutine testProcDecl(arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11)
-      !WARNING: Attribute 'INTENT(IN)' cannot be used more than once
+      !WARNING: Attribute 'INTENT(IN)' cannot be used more than once [-Wno-redundant-attribute]
       procedure(procFunc), intent(in), pointer, intent(in) :: arg4
-      !WARNING: Attribute 'INTENT(OUT)' cannot be used more than once
+      !WARNING: Attribute 'INTENT(OUT)' cannot be used more than once [-Wno-redundant-attribute]
       procedure(procFunc), intent(out), pointer, intent(out) :: arg5
-      !WARNING: Attribute 'INTENT(INOUT)' cannot be used more than once
+      !WARNING: Attribute 'INTENT(INOUT)' cannot be used more than once [-Wno-redundant-attribute]
       procedure(procFunc), intent(inout), pointer, intent(inout) :: arg6
       !ERROR: Attributes 'INTENT(INOUT)' and 'INTENT(OUT)' conflict with each other
       procedure(procFunc), intent(inout), pointer, intent(out) :: arg7
       !ERROR: Attributes 'INTENT(INOUT)' and 'INTENT(OUT)' conflict with each other
       procedure(procFunc), intent(out), pointer, intent(inout) :: arg8
-      !WARNING: Attribute 'OPTIONAL' cannot be used more than once
+      !WARNING: Attribute 'OPTIONAL' cannot be used more than once [-Wno-redundant-attribute]
       procedure(procFunc), optional, pointer, optional :: arg9
-      !WARNING: Attribute 'POINTER' cannot be used more than once
+      !WARNING: Attribute 'POINTER' cannot be used more than once [-Wno-redundant-attribute]
       procedure(procFunc), pointer, optional, pointer :: arg10
-      !WARNING: Attribute 'SAVE' cannot be used more than once
+      !WARNING: Attribute 'SAVE' cannot be used more than once [-Wno-redundant-attribute]
       procedure(procFunc), save, pointer, save :: localProc
       !ERROR: A PROTECTED entity must be in the specification part of a module
       real x
diff --git a/flang/test/Semantics/resolve83.f90 b/flang/test/Semantics/resolve83.f90
index e9d53dd6bd81d..2d4adc2c48845 100644
--- a/flang/test/Semantics/resolve83.f90
+++ b/flang/test/Semantics/resolve83.f90
@@ -3,7 +3,7 @@ module m
 
   ! For C1543
   interface intFace
-    !WARNING: Attribute 'MODULE' cannot be used more than once
+    !WARNING: Attribute 'MODULE' cannot be used more than once [-Wno-redundant-attribute]
     module pure module real function moduleFunc()
     end function moduleFunc
   end interface
@@ -27,17 +27,17 @@ end function moduleFunc
     real pure real function realFunc()
     end function realFunc
 
-    !WARNING: Attribute 'ELEMENTAL' cannot be used more than once
+    !WARNING: Attribute 'ELEMENTAL' cannot be used more than once [-Wno-redundant-attribute]
     elemental real elemental function elementalFunc(x)
       real, value :: x
       elementalFunc = x
     end function elementalFunc
 
-    !WARNING: Attribute 'IMPURE' cannot be used more than once
+    !WARNING: Attribute 'IMPURE' cannot be used more than once [-Wno-redundant-attribute]
     impure real impure function impureFunc()
     end function impureFunc
 
-    !WARNING: Attribute 'PURE' cannot be used more than once
+    !WARNING: Attribute 'PURE' cannot be used more than once [-Wno-redundant-attribute]
     pure real pure function pureFunc()
     end function pureFunc
 
@@ -45,11 +45,11 @@ end function pureFunc
     impure real pure function impurePureFunc()
     end function impurePureFunc
 
-    !WARNING: Attribute 'RECURSIVE' cannot be used more than once
+    !WARNING: Attribute 'RECURSIVE' cannot be used more than once [-Wno-redundant-attribute]
     recursive real recursive function recursiveFunc()
     end function recursiveFunc
 
-    !WARNING: Attribute 'NON_RECURSIVE' cannot be used more than once
+    !WARNING: Attribute 'NON_RECURSIVE' cannot be used more than once [-Wno-redundant-attribute]
     non_recursive real non_recursive function non_recursiveFunc()
     end function non_recursiveFunc
 
diff --git a/flang/test/Semantics/resolve85.f90 b/flang/test/Semantics/resolve85.f90
index 9b9358ecf4770..03d4db410fd71 100644
--- a/flang/test/Semantics/resolve85.f90
+++ b/flang/test/Semantics/resolve85.f90
@@ -7,15 +7,15 @@ module m
 !        TYPE [[, type-attr-spec-list] ::] type-name [( type-param-name-list )]
 !  type-attr-spec values are:
 !    ABSTRACT, PUBLIC, PRIVATE, BIND(C), EXTENDS(parent-type-name)
-  !WARNING: Attribute 'ABSTRACT' cannot be used more than once
+  !WARNING: Attribute 'ABSTRACT' cannot be used more than once [-Wno-redundant-attribute]
   type, abstract, public, abstract :: derived1
   end type derived1
 
-  !WARNING: Attribute 'PUBLIC' cannot be used more than once
+  !WARNING: Attribute 'PUBLIC' cannot be used more than once [-Wno-redundant-attribute]
   type, public, abstract, public :: derived2
   end type derived2
 
-  !WARNING: Attribute 'PRIVATE' cannot be used more than once
+  !WARNING: Attribute 'PRIVATE' cannot be used more than once [-Wno-redundant-attribute]
   type, private, abstract, private :: derived3
   end type derived3
 
@@ -23,8 +23,8 @@ module m
   type, public, abstract, private :: derived4
   end type derived4
 
-  !WARNING: Attribute 'BIND(C)' cannot be used more than once
-  !WARNING: A derived type with the BIND attribute should not be empty
+  !WARNING: Attribute 'BIND(C)' cannot be used more than once [-Wno-redundant-attribute]
+  !WARNING: A derived type with the BIND attribute should not be empty [-Wno-empty-bind-c-derived-type]
   type, bind(c), public, bind(c) :: derived5
   end type derived5
 
diff --git a/flang/test/Semantics/resolve90.f90 b/flang/test/Semantics/resolve90.f90
index baa108f4d0839..519654f980f25 100644
--- a/flang/test/Semantics/resolve90.f90
+++ b/flang/test/Semantics/resolve90.f90
@@ -12,7 +12,7 @@ subroutine s()
     !ERROR: 'pointerallocatablefield' may not have both the POINTER and ALLOCATABLE attributes
     real, pointer, allocatable :: pointerAllocatableField
     real, dimension(:), contiguous, pointer :: goodContigField
-    !PORTABILITY: CONTIGUOUS component 'badcontigfield' should be an array with the POINTER attribute
+    !PORTABILITY: CONTIGUOUS component 'badcontigfield' should be an array with the POINTER attribute [-Wno-redundant-contiguous]
     real, dimension(:), contiguous, allocatable :: badContigField
     character :: charField * 3
     !ERROR: A length specifier cannot be used to declare the non-character entity 'realfield'
diff --git a/flang/test/Semantics/resolve99.f90 b/flang/test/Semantics/resolve99.f90
index e56022b61bfd8..dd1b2d66ef438 100644
--- a/flang/test/Semantics/resolve99.f90
+++ b/flang/test/Semantics/resolve99.f90
@@ -31,7 +31,7 @@ subroutine constructAssoc()
     integer, dimension(4) :: table
     integer :: localVar
     associate (assocVar => localVar)
-      !PORTABILITY: Index variable 'assocvar' should be a scalar object or common block if it is present in the enclosing scope
+      !PORTABILITY: Index variable 'assocvar' should be a scalar object or common block if it is present in the enclosing scope [-Wno-odd-index-variable-restrictions]
       FORALL (assocVar=1:4) table(assocVar) = 343
     end associate
   end subroutine constructAssoc
@@ -44,7 +44,7 @@ end subroutine commonSub
 
   subroutine mismatch()
     integer, dimension(4) :: table
-    !PORTABILITY: Index variable 'typename' should be a scalar object or common block if it is present in the enclosing scope
+    !PORTABILITY: Index variable 'typename' should be a scalar object or common block if it is present in the enclosing scope [-Wno-odd-index-variable-restrictions]
     !ERROR: Must have INTEGER type, but is REAL(4)
     !ERROR: Must have INTEGER type, but is REAL(4)
     FORALL (typeName=1:4) table(typeName) = 343
diff --git a/flang/test/Semantics/separate-mp02.f90 b/flang/test/Semantics/separate-mp02.f90
index cb1e2687bad73..4f9732144f050 100644
--- a/flang/test/Semantics/separate-mp02.f90
+++ b/flang/test/Semantics/separate-mp02.f90
@@ -368,7 +368,7 @@ module subroutine s(x)
 end
 submodule(m11) sm11
  contains
-  !WARNING: Dummy procedure 'x' does not exactly match the corresponding argument in the interface body
+  !WARNING: Dummy procedure 'x' does not exactly match the corresponding argument in the interface body [-Wno-mismatching-dummy-procedure]
   module subroutine s(x)
     call x ! no error
   end
diff --git a/flang/test/Semantics/spec-expr.f90 b/flang/test/Semantics/spec-expr.f90
index 28ebea1109f1d..e59fae9beb2ca 100644
--- a/flang/test/Semantics/spec-expr.f90
+++ b/flang/test/Semantics/spec-expr.f90
@@ -117,7 +117,7 @@ subroutine s7biii(x, y)
   integer :: local = 5
   ! OK, since "localConst" is a constant
   real, dimension(localConst) :: realArray1
-  !PORTABILITY: specification expression refers to local object 'local' (initialized and saved)
+  !PORTABILITY: specification expression refers to local object 'local' (initialized and saved) [-Wno-saved-local-in-spec-expr]
   real, dimension(local) :: realArray2
   real, dimension(size(realArray1)) :: realArray3 ! ok
   real, dimension(size(x)) :: realArray4 ! ok
diff --git a/flang/test/Semantics/stmt-func01.f90 b/flang/test/Semantics/stmt-func01.f90
index a87b0d7af52b4..b9d22232face2 100644
--- a/flang/test/Semantics/stmt-func01.f90
+++ b/flang/test/Semantics/stmt-func01.f90
@@ -10,14 +10,14 @@ program main
     pure integer function ifunc()
     end function
   end interface
-  !PORTABILITY: Automatic data object 'x1' should not appear in the specification part of a main program
+  !PORTABILITY: Automatic data object 'x1' should not appear in the specification part of a main program [-Wno-automatic-in-main-program]
   type(t1(k=4,l=ifunc())) x1
-  !PORTABILITY: Statement function 'sf1' should not contain an array constructor
+  !PORTABILITY: Statement function 'sf1' should not contain an array constructor [-Wno-statement-function-extensions]
   sf1(n) = sum([(j,j=1,n)])
   type(t1) sf2
-  !PORTABILITY: Statement function 'sf2' should not contain a structure constructor
+  !PORTABILITY: Statement function 'sf2' should not contain a structure constructor [-Wno-statement-function-extensions]
   sf2(n) = t1(n)
-  !PORTABILITY: Statement function 'sf3' should not contain a type parameter inquiry
+  !PORTABILITY: Statement function 'sf3' should not contain a type parameter inquiry [-Wno-statement-function-extensions]
   sf3(n) = x1%l
   !ERROR: Recursive call to statement function 'sf4' is not allowed
   sf4(n) = sf4(n)
@@ -26,10 +26,10 @@ pure integer function ifunc()
   real sf7
   !ERROR: Statement function 'sf6' may not reference another statement function 'sf7' that is defined later
   sf6(n) = sf7(n)
-  !PORTABILITY: Statement function 'sf7' should not reference function 'explicit' that requires an explicit interface
+  !PORTABILITY: Statement function 'sf7' should not reference function 'explicit' that requires an explicit interface [-Wno-statement-function-extensions]
   sf7(n) = explicit(n)
   real :: a(3) = [1., 2., 3.]
-  !PORTABILITY: Statement function 'sf8' should not pass an array argument that is not a whole array
+  !PORTABILITY: Statement function 'sf8' should not pass an array argument that is not a whole array [-Wno-statement-function-extensions]
   sf8(n) = sum(a(1:2))
   sf8a(n) = sum(a) ! ok
   integer :: sf9
@@ -56,7 +56,7 @@ pure function arr()
     arr = [1., 2.]
   end function
   subroutine foo
-    !PORTABILITY: An implicitly typed statement function should not appear when the same symbol is available in its host scope
+    !PORTABILITY: An implicitly typed statement function should not appear when the same symbol is available in its host scope [-Wno-statement-function-extensions]
     sf14(x) = 2.*x
   end subroutine
 end
@@ -94,7 +94,7 @@ subroutine s4
 subroutine s5
   !ERROR: Invalid specification expression: reference to impure function 'k'
   real x(k())
-  !WARNING: Name 'k' from host scope should have a type declaration before its local statement function definition
+  !WARNING: Name 'k' from host scope should have a type declaration before its local statement function definition [-Wno-statement-function-extensions]
   !ERROR: 'k' is already declared in this scoping unit
   k() = 0.0
 end
diff --git a/flang/test/Semantics/stmt-func02.f90 b/flang/test/Semantics/stmt-func02.f90
index bfed280ded58d..e7983af693c90 100644
--- a/flang/test/Semantics/stmt-func02.f90
+++ b/flang/test/Semantics/stmt-func02.f90
@@ -24,11 +24,11 @@ subroutine test1
     print *, x
   end
   subroutine test2
-    !PORTABILITY: Name 'rf' from host scope should have a type declaration before its local statement function definition
+    !PORTABILITY: Name 'rf' from host scope should have a type declaration before its local statement function definition [-Wno-statement-function-extensions]
     rf(x) = 1.
   end
   subroutine test2b
-    !PORTABILITY: Name 'rf2' from host scope should have a type declaration before its local statement function definition
+    !PORTABILITY: Name 'rf2' from host scope should have a type declaration before its local statement function definition [-Wno-statement-function-extensions]
     rf2(x) = 1.
   end
   subroutine test3
@@ -43,7 +43,7 @@ function f()
     f() = 1. ! statement function of same name as function
   end
   function g() result(r)
-    !WARNING: Name 'g' from host scope should have a type declaration before its local statement function definition
+    !WARNING: Name 'g' from host scope should have a type declaration before its local statement function definition [-Wno-statement-function-extensions]
     !ERROR: 'g' is already declared in this scoping unit
     g() = 1. ! statement function of same name as function
   end
diff --git a/flang/test/Semantics/structconst03.f90 b/flang/test/Semantics/structconst03.f90
index ecd31723b12bb..76248fd06dd97 100644
--- a/flang/test/Semantics/structconst03.f90
+++ b/flang/test/Semantics/structconst03.f90
@@ -183,7 +183,7 @@ impure real function ipf1(dummy1, dummy2, dummy3, dummy4)
     x1 = t1(0)(usedfrom1)
     x1 = t1(0)(modulevar1)
     x1 = t1(0)(commonvar1)
-    !WARNING: Pointer target is not a definable variable
+    !WARNING: Pointer target is not a definable variable [-Wno-pointer-to-undefinable]
     !BECAUSE: 'dummy1' is an INTENT(IN) dummy argument
     x1 = t1(0)(dummy1)
     x1 = t1(0)(dummy2)
diff --git a/flang/test/Semantics/structconst04.f90 b/flang/test/Semantics/structconst04.f90
index abddf6001726c..0263b7fda2bc9 100644
--- a/flang/test/Semantics/structconst04.f90
+++ b/flang/test/Semantics/structconst04.f90
@@ -177,7 +177,7 @@ impure real function ipf1(dummy1, dummy2, dummy3, dummy4)
     x1 = t1(usedfrom1)
     x1 = t1(modulevar1)
     x1 = t1(commonvar1)
-    !WARNING: Pointer target is not a definable variable
+    !WARNING: Pointer target is not a definable variable [-Wno-pointer-to-undefinable]
     !BECAUSE: 'dummy1' is an INTENT(IN) dummy argument
     x1 = t1(dummy1)
     x1 = t1(dummy2)
diff --git a/flang/test/Semantics/structconst08.f90 b/flang/test/Semantics/structconst08.f90
index 149c898dda9d4..04f648cd93d0c 100644
--- a/flang/test/Semantics/structconst08.f90
+++ b/flang/test/Semantics/structconst08.f90
@@ -25,7 +25,7 @@ subroutine test1()
 !ERROR: Must be a constant value
     type(parent1) :: tp2 = parent1(j)
     type(parent1) :: tp3 = parent1(null())
-!PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'pa'
+!PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'pa' [-Wno-null-mold-allocatable-component-value]
     type(parent1) :: tp4 = parent1(null(ipp))
 
 !ERROR: Must be a constant value
@@ -33,7 +33,7 @@ subroutine test1()
 !ERROR: Must be a constant value
     type(parent2) :: tp6 = parent2(arr)
     type(parent2) :: tp7 = parent2(null())
-!PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'pa'
+!PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'pa' [-Wno-null-mold-allocatable-component-value]
     type(parent2) :: tp8 = parent2(null(rpp))
   end subroutine test1
 
@@ -47,20 +47,20 @@ subroutine test2()
     tp1 = parent1(3)
     tp1 = parent1(j)
     tp1 = parent1(null())
-!PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'pa'
+!PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'pa' [-Wno-null-mold-allocatable-component-value]
     tp1 = parent1(null(ipp))
 
     tp2 = parent2([1.1,2.1,3.1])
     tp2 = parent2(arr)
     tp2 = parent2(null())
-!PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'pa'
+!PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'pa' [-Wno-null-mold-allocatable-component-value]
     tp2 = parent2(null(rpp))
   end subroutine test2
 
   subroutine test3()
     real, pointer :: pp(:)
     type(child) :: tc1 = child(5, parent2(null()))
-!PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'pa'
+!PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'pa' [-Wno-null-mold-allocatable-component-value]
     type(child) :: tc10 = child(5, parent2(null(pp)))
 !ERROR: Must be a constant value
     type(child) :: tc3 = child(5, parent2([1.1,1.2]))
diff --git a/flang/test/Semantics/structconst10.f90 b/flang/test/Semantics/structconst10.f90
index 582f8fc15704f..d5cc86b368174 100644
--- a/flang/test/Semantics/structconst10.f90
+++ b/flang/test/Semantics/structconst10.f90
@@ -14,12 +14,12 @@ end module m1
 program test
   use m1
   type(a3) v
-  !PORTABILITY: Whole parent component 'a2' in structure constructor should not be anonymous
+  !PORTABILITY: Whole parent component 'a2' in structure constructor should not be anonymous [-Wno-anonymous-parents]
   v=a3(a2(x1=18,x2=6),x3=6)
-  !PORTABILITY: Whole parent component 'a1' in structure constructor should not be anonymous
+  !PORTABILITY: Whole parent component 'a1' in structure constructor should not be anonymous [-Wno-anonymous-parents]
   v=a3(a1(x1=18),x2=6,x3=6)
-  !PORTABILITY: Whole parent component 'a2' in structure constructor should not be anonymous
-  !PORTABILITY: Whole parent component 'a1' in structure constructor should not be anonymous
+  !PORTABILITY: Whole parent component 'a2' in structure constructor should not be anonymous [-Wno-anonymous-parents]
+  !PORTABILITY: Whole parent component 'a1' in structure constructor should not be anonymous [-Wno-anonymous-parents]
   v=a3(a2(a1(x1=18),x2=6),x3=6)
   v=a3(a2=a2(a1=a1(x1=18),x2=6),x3=6) ! ok
 end
diff --git a/flang/test/Semantics/transfer01.f90 b/flang/test/Semantics/transfer01.f90
index 26f4f1b3eb62f..05b8b093beb67 100644
--- a/flang/test/Semantics/transfer01.f90
+++ b/flang/test/Semantics/transfer01.f90
@@ -20,17 +20,17 @@ subroutine subr(o)
   print *, transfer(1., empty2) ! ok
   !ERROR: Element size of MOLD= array may not be zero when SOURCE= is not empty
   print *, transfer(1., empty3)
-  !WARNING: Element size of MOLD= array may not be zero unless SOURCE= is empty
+  !WARNING: Element size of MOLD= array may not be zero unless SOURCE= is empty [-Wno-void-mold]
   print *, transfer(source, empty1)
   print *, transfer(source, empty2) ! ok
-  !WARNING: Element size of MOLD= array may not be zero unless SOURCE= is empty
+  !WARNING: Element size of MOLD= array may not be zero unless SOURCE= is empty [-Wno-void-mold]
   print *, transfer(source, empty3)
   !ERROR: SIZE= argument may not be the optional dummy argument 'o'
   print *, transfer(1., empty2, size=o)
-  !WARNING: SIZE= argument that is allocatable or pointer must be present at execution; parenthesize to silence this warning
+  !WARNING: SIZE= argument that is allocatable or pointer must be present at execution; parenthesize to silence this warning [-Wno-transfer-size-presence]
   print *, transfer(1., empty2, size=ia)
-  !WARNING: SIZE= argument that is allocatable or pointer must be present at execution; parenthesize to silence this warning
+  !WARNING: SIZE= argument that is allocatable or pointer must be present at execution; parenthesize to silence this warning [-Wno-transfer-size-presence]
   print *, transfer(1., empty2, size=ip)
-  !WARNING: Source of TRANSFER contains allocatable or pointer component %allocatable
+  !WARNING: Source of TRANSFER contains allocatable or pointer component %allocatable [-Wno-pointer-component-transfer-arg]
   print *, transfer(hasDesc, 1)
 end
diff --git a/flang/test/Semantics/undef-result01.f90 b/flang/test/Semantics/undef-result01.f90
index e1ae58dae7c0a..f002155d9ee57 100644
--- a/flang/test/Semantics/undef-result01.f90
+++ b/flang/test/Semantics/undef-result01.f90
@@ -1,6 +1,6 @@
 ! RUN: %python %S/test_errors.py %s %flang_fc1 -Werror
 
-!WARNING: Function result is never defined
+!WARNING: Function result is never defined [-Wno-undefined-function-result]
 function basic()
 end
 
@@ -29,7 +29,7 @@ subroutine intentInPtr(p)
   end
 end
 
-!WARNING: Function result is never defined
+!WARNING: Function result is never defined [-Wno-undefined-function-result]
 function notDefdByCall()
   call intentin(notDefdByCall)
  contains
@@ -38,7 +38,7 @@ subroutine intentin(n)
   end
 end
 
-!WARNING: Function result is never defined
+!WARNING: Function result is never defined [-Wno-undefined-function-result]
 function basicAlloc()
   real, allocatable :: basicAlloc
   allocate(basicAlloc)
@@ -134,7 +134,7 @@ integer function defdBySize()
   inquire(6,status=defdByInquire)
 end
 
-!WARNING: Function result is never defined
+!WARNING: Function result is never defined [-Wno-undefined-function-result]
 character(20) function notDefdByInquire()
   inquire(file=notDefdByInquire)
 end
diff --git a/flang/unittests/Common/FortranFeaturesTest.cpp b/flang/unittests/Common/FortranFeaturesTest.cpp
index afd677f69a165..9d8a7c7b17f6f 100644
--- a/flang/unittests/Common/FortranFeaturesTest.cpp
+++ b/flang/unittests/Common/FortranFeaturesTest.cpp
@@ -558,4 +558,10 @@ TEST(FortranFeaturesTest, CamelCaseToLowerCaseHyphenated) {
       "non-volatile-pointer-to-volatile");
 }
 
+TEST(FortranFeaturesTest, HintLanguageControlFlag) {
+  LanguageFeatureControl control{};
+  EXPECT_EQ(control.getDefaultCliSpelling(LanguageFeature::BenignNameClash), "benign-name-clash");
+  EXPECT_EQ(control.getDefaultCliSpelling(UsageWarning::Portability), "portability");
+}
+
 } // namespace Fortran::common::details



More information about the flang-commits mailing list