[libc-commits] [libc] [libc] Add -Werror for libc tests (PR #160413)

Vinay Deshmukh via libc-commits libc-commits at lists.llvm.org
Sat Sep 27 17:38:40 PDT 2025


https://github.com/vinay-deshmukh updated https://github.com/llvm/llvm-project/pull/160413

>From 9576513f202177c8733c6cb9fe82c9df5f88ad29 Mon Sep 17 00:00:00 2001
From: Vinay Deshmukh <vinay_deshmukh at outlook.com>
Date: Tue, 23 Sep 2025 19:48:33 -0400
Subject: [PATCH 1/2] -Werror

---
 libc/cmake/modules/LLVMLibCTestRules.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index 19da0ad29cd84..34abc0a58f8cd 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -43,7 +43,7 @@ function(_get_common_test_compile_options output_var c_test flags)
     list(APPEND compile_options "-Wextra")
     # -DLIBC_WNO_ERROR=ON if you can't build cleanly with -Werror.
     if(NOT LIBC_WNO_ERROR)
-      # list(APPEND compile_options "-Werror")
+      list(APPEND compile_options "-Werror")
     endif()
     list(APPEND compile_options "-Wconversion")
     # FIXME: convert to -Wsign-conversion

>From 26fe540482a2247518492ee1ca3a47721d25b897 Mon Sep 17 00:00:00 2001
From: Vinay Deshmukh <vinay_deshmukh at outlook.com>
Date: Sat, 27 Sep 2025 20:37:45 -0400
Subject: [PATCH 2/2] error: implicit conversion loses integer precision:
 'unsigned long' to 'int' [-Werror,-Wshorten-64-to-32]

---
 libc/test/src/stdio/fileop_test.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/test/src/stdio/fileop_test.cpp b/libc/test/src/stdio/fileop_test.cpp
index 02328042b92b3..da9a062e83bf2 100644
--- a/libc/test/src/stdio/fileop_test.cpp
+++ b/libc/test/src/stdio/fileop_test.cpp
@@ -100,7 +100,7 @@ TEST_F(LlvmLibcFILETest, SimpleFileOperations) {
   ASSERT_EQ(LIBC_NAMESPACE::ferror(file), 0);
 
   // This is not a readable file.
-  ASSERT_THAT(LIBC_NAMESPACE::fread(data, 1, 1, file),
+  ASSERT_THAT((int)LIBC_NAMESPACE::fread(data, 1, 1, file),
               returns(EQ(0)).with_errno(NE(0)));
 
   ASSERT_EQ(0, LIBC_NAMESPACE::fclose(file));



More information about the libc-commits mailing list