[libcxx-commits] [libcxx] 3779bcb - [libc++] Switch the enable_warnings Lit parameter to enable_werror (#214113)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Aug 7 05:13:34 PDT 2026


Author: Louis Dionne
Date: 2026-08-07T08:13:29-04:00
New Revision: 3779bcb1b7bd9d7d82ee43b232e1a98c14e1b104

URL: https://github.com/llvm/llvm-project/commit/3779bcb1b7bd9d7d82ee43b232e1a98c14e1b104
DIFF: https://github.com/llvm/llvm-project/commit/3779bcb1b7bd9d7d82ee43b232e1a98c14e1b104.diff

LOG: [libc++] Switch the enable_warnings Lit parameter to enable_werror (#214113)

Our enable_warnings=False parameter in the test suite was basically not
working as intended. Instead of disabling warnings, it would disable all
warning-related flags, including flags that are required for the test
suite to pass (e.g. -Wno-user-defined-literals). As a result, it
couldn't be turned off.

Remove enable_warnings and introduce enable_werror instead. That way, we
can disable -Werror in the test suite but the warnings (and -Wno-foo)
are always used, which is necessary for the test suite to function.

Note that the ability to run the test suite without -Werror is necessary
in order to test against other implementations, including older versions
of libc++ itself.

Added: 
    

Modified: 
    libcxx/test/libcxx/diagnostics/unused_variables.verify.cpp
    libcxx/utils/libcxx/test/params.py

Removed: 
    libcxx/test/selftest/pass.cpp/werror.pass.cpp
    libcxx/test/selftest/sh.cpp/werror.sh.cpp


################################################################################
diff  --git a/libcxx/test/libcxx/diagnostics/unused_variables.verify.cpp b/libcxx/test/libcxx/diagnostics/unused_variables.verify.cpp
index c36e32d67e37f..e99315648bdfe 100644
--- a/libcxx/test/libcxx/diagnostics/unused_variables.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/unused_variables.verify.cpp
@@ -7,6 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 // Make sure that we warn on unused variables of libc++ classes which behave like value types.
+// ADDITIONAL_COMPILE_FLAGS: -Wunused-variable
 
 #include <deque>
 #include <forward_list>

diff  --git a/libcxx/test/selftest/pass.cpp/werror.pass.cpp b/libcxx/test/selftest/pass.cpp/werror.pass.cpp
deleted file mode 100644
index 16039abc4c001..0000000000000
--- a/libcxx/test/selftest/pass.cpp/werror.pass.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// XFAIL: *
-
-// Make sure that even a simple unused variable warning is treated as an
-// error in the test suite. This is to make sure the test suite always runs
-// with -Werror.
-
-// ADDITIONAL_COMPILE_FLAGS: -Wunused-variable
-
-// TODO: We don't enable -Werror on GCC right now, because too many tests fail.
-// UNSUPPORTED: gcc
-
-int main(int, char**) {
-    int foo;
-    return 0;
-}

diff  --git a/libcxx/test/selftest/sh.cpp/werror.sh.cpp b/libcxx/test/selftest/sh.cpp/werror.sh.cpp
deleted file mode 100644
index 3188f57ec8fd1..0000000000000
--- a/libcxx/test/selftest/sh.cpp/werror.sh.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// XFAIL: *
-
-// Make sure that even a simple unused variable warning is treated as an
-// error in the test suite, including in .sh.cpp tests.
-
-// TODO: We don't enable -Werror on GCC right now, because too many tests fail.
-// UNSUPPORTED: gcc
-
-// RUN: %{build} -Wunused-variable
-// RUN: %{run}
-
-int main(int, char**) {
-    int foo;
-    return 0;
-}

diff  --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py
index 909815694c2cc..4a14ed0697b84 100644
--- a/libcxx/utils/libcxx/test/params.py
+++ b/libcxx/utils/libcxx/test/params.py
@@ -15,7 +15,6 @@
 
 
 _warningFlags = [
-    "-Werror",
     "-Wall",
     "-Wctad-maybe-unsupported",
     "-Wextra",
@@ -289,14 +288,14 @@ def getSuitableClangTidy(cfg):
         actions=lambda is_system: [AddFeature("stdlib=system")] if is_system else [],
     ),
     Parameter(
-        name="enable_warnings",
+        name="enable_werror",
         choices=[True, False],
         type=bool,
         default=True,
-        help="Whether to enable warnings when compiling the test suite.",
-        actions=lambda warnings: [] if not warnings else
-            [AddOptionalWarningFlag(w) for w in _warningFlags] +
-            [AddCompileFlag("-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER")],
+        help="Whether to treat warnings as errors when compiling the test suite.",
+        actions=lambda werror: [AddOptionalWarningFlag(w) for w in _warningFlags] +
+                               [AddCompileFlag("-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER")] +
+                               ([AddCompileFlag("-Werror")] if werror else []),
     ),
     Parameter(
         name="use_sanitizer",


        


More information about the libcxx-commits mailing list