[llvm] [libc] [libc][NFC] Fix "type qualifiers ignored on cast result type" GCC warning (PR #78509)
Guillaume Chatelet via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 18 07:26:05 PST 2024
https://github.com/gchatelet updated https://github.com/llvm/llvm-project/pull/78509
>From c3b57887b9a3c04f61883aafd11cffdb301ea2c5 Mon Sep 17 00:00:00 2001
From: Guillaume Chatelet <gchatelet at google.com>
Date: Wed, 17 Jan 2024 22:07:11 +0000
Subject: [PATCH 1/2] [libc][NFC] Fix GCC volatile warning
GCC complains about "type qualifiers ignored on cast result type"
---
libc/test/src/__support/FPUtil/dyadic_float_test.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/test/src/__support/FPUtil/dyadic_float_test.cpp b/libc/test/src/__support/FPUtil/dyadic_float_test.cpp
index 8fafa767ae38e34..4ab270c63628a30 100644
--- a/libc/test/src/__support/FPUtil/dyadic_float_test.cpp
+++ b/libc/test/src/__support/FPUtil/dyadic_float_test.cpp
@@ -48,7 +48,7 @@ TEST(LlvmLibcDyadicFloatTest, QuickAdd) {
Float192 z = quick_add(x, y);
- EXPECT_FP_EQ_ALL_ROUNDING(xd + yd, (volatile double)(z));
+ EXPECT_FP_EQ_ALL_ROUNDING(xd + yd, double(z));
}
TEST(LlvmLibcDyadicFloatTest, QuickMul) {
>From a4ab2cce6398c564c9a97c97595eb78c19d2cc7c Mon Sep 17 00:00:00 2001
From: Guillaume Chatelet <gchatelet at google.com>
Date: Thu, 18 Jan 2024 15:25:48 +0000
Subject: [PATCH 2/2] Add "-frounding-math" to math tests
---
libc/test/src/CMakeLists.txt | 6 +++++-
.../llvm-project-overlay/libc/test/libc_test_rules.bzl | 1 +
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/libc/test/src/CMakeLists.txt b/libc/test/src/CMakeLists.txt
index 6bd8ace9ea71af0..dacd8664e512c3f 100644
--- a/libc/test/src/CMakeLists.txt
+++ b/libc/test/src/CMakeLists.txt
@@ -3,7 +3,7 @@ function(add_fp_unittest name)
"MATH_UNITTEST"
"NEED_MPFR;UNIT_TEST_ONLY;HERMETIC_TEST_ONLY" # Optional arguments
"" # Single value arguments
- "LINK_LIBRARIES" # Multi-value arguments
+ "LINK_LIBRARIES;COMPILE_OPTIONS" # Multi-value arguments
${ARGN}
)
@@ -28,10 +28,14 @@ function(add_fp_unittest name)
endif()
list(APPEND MATH_UNITTEST_LINK_LIBRARIES LibcFPTestHelpers)
+ if (NOT "-frounding-math" IN_LIST MATH_UNITTEST_COMPILE_OPTIONS)
+ list(APPEND MATH_UNITTEST_COMPILE_OPTIONS "-frounding-math")
+ endif()
add_libc_test(
${name}
${test_type}
LINK_LIBRARIES "${MATH_UNITTEST_LINK_LIBRARIES}"
+ COMPILE_OPTIONS "${MATH_UNITTEST_COMPILE_OPTIONS}"
"${MATH_UNITTEST_UNPARSED_ARGUMENTS}"
)
endfunction(add_fp_unittest)
diff --git a/utils/bazel/llvm-project-overlay/libc/test/libc_test_rules.bzl b/utils/bazel/llvm-project-overlay/libc/test/libc_test_rules.bzl
index 18056bacfd50cea..4e819257e1c523c 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/libc_test_rules.bzl
+++ b/utils/bazel/llvm-project-overlay/libc/test/libc_test_rules.bzl
@@ -26,6 +26,7 @@ def libc_test(name, srcs, libc_function_deps = [], copts = [], deps = [], **kwar
**kwargs: Attributes relevant for a libc_test. For example, name, srcs.
"""
all_function_deps = libc_function_deps + ["//libc:errno"]
+ copts = copts + ["-frounding-math"]
native.cc_test(
name = name,
srcs = srcs,
More information about the llvm-commits
mailing list