[flang-commits] [flang] [llvm] [flang] Try -Werror by default (take 2) (PR #175819)

via flang-commits flang-commits at lists.llvm.org
Tue Jan 13 11:36:22 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

<details>
<summary>Changes</summary>

Fix two legitimate warnings found by build bots the last time that I tried to re-enable -Werror builds of flang-new by default, and turn it back on for another try.

---
Full diff: https://github.com/llvm/llvm-project/pull/175819.diff


3 Files Affected:

- (modified) flang/CMakeLists.txt (+1-1) 
- (modified) flang/include/flang/Semantics/dump-expr.h (+1-1) 
- (modified) llvm/include/llvm/ProfileData/InstrProf.h (+6-4) 


``````````diff
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index c01eb56d5e496..390cfe749f962 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -37,7 +37,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE)
           `CMakeFiles'. Please delete them.")
 endif()
 
-option(FLANG_ENABLE_WERROR "Fail and stop building flang if a warning is triggered." OFF)
+option(FLANG_ENABLE_WERROR "Fail and stop building flang if a warning is triggered." ON)
 
 # Check for a standalone build and configure as appropriate from
 # there.
diff --git a/flang/include/flang/Semantics/dump-expr.h b/flang/include/flang/Semantics/dump-expr.h
index 5a78e13b19e5d..83f9be889d734 100644
--- a/flang/include/flang/Semantics/dump-expr.h
+++ b/flang/include/flang/Semantics/dump-expr.h
@@ -203,7 +203,7 @@ class DumpEvaluateExpr {
   }
   void Show(const evaluate::Relational<evaluate::SomeType> &x);
   template <typename T> void Show(const evaluate::Expr<T> &x) {
-    Indent("expr <" + std::string(TypeOf<T>::name) + ">");
+    Indent("expr <"s + std::string(TypeOf<T>::name) + ">");
     Show(x.u);
     Outdent();
   }
diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h
index f59ddc3e59324..7f5c16936ef28 100644
--- a/llvm/include/llvm/ProfileData/InstrProf.h
+++ b/llvm/include/llvm/ProfileData/InstrProf.h
@@ -1024,8 +1024,9 @@ struct InstrProfRecord {
   getValueSitesForKind(uint32_t ValueKind) const {
     if (!ValueData)
       return {};
-    assert(IPVK_First <= ValueKind && ValueKind <= IPVK_Last &&
-           "Unknown value kind!");
+    if constexpr (IPVK_First > 0)
+      assert(IPVK_First <= ValueKind && "Unknown value kind!");
+    assert(ValueKind <= IPVK_Last && "Unknown value kind!");
     return (*ValueData)[ValueKind - IPVK_First];
   }
 
@@ -1033,8 +1034,9 @@ struct InstrProfRecord {
   getOrCreateValueSitesForKind(uint32_t ValueKind) {
     if (!ValueData)
       ValueData = std::make_unique<ValueProfData>();
-    assert(IPVK_First <= ValueKind && ValueKind <= IPVK_Last &&
-           "Unknown value kind!");
+    if constexpr (IPVK_First > 0)
+      assert(IPVK_First <= ValueKind && "Unknown value kind!");
+    assert(ValueKind <= IPVK_Last && "Unknown value kind!");
     return (*ValueData)[ValueKind - IPVK_First];
   }
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/175819


More information about the flang-commits mailing list