[libc-commits] [libc] [libc] Build with -Wdeprecated, fix some warnings (PR #125373)
via libc-commits
libc-commits at lists.llvm.org
Sat Feb 1 17:34:52 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Roland McGrath (frobtech)
<details>
<summary>Changes</summary>
While GCC's -Wdeprecated is on by default and doesn't do much,
Clang's -Wdeprecated enables many more things. More apply in
C++20, so switch a test file that tickled one to using that. In
future, C++20 should probably be made the baseline for compiling
all the libc code.
---
Full diff: https://github.com/llvm/llvm-project/pull/125373.diff
4 Files Affected:
- (modified) libc/cmake/modules/LLVMLibCCompileOptionRules.cmake (+2-1)
- (modified) libc/src/__support/CPP/span.h (+2)
- (modified) libc/test/src/setjmp/CMakeLists.txt (+2)
- (modified) libc/test/src/setjmp/setjmp_test.cpp (+1-1)
``````````diff
diff --git a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
index 12420db331961bf..0facb0b9be0c134 100644
--- a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
+++ b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
@@ -179,8 +179,9 @@ function(_get_common_compile_options output_var flags)
endif()
list(APPEND compile_options "-Wconversion")
list(APPEND compile_options "-Wno-sign-conversion")
- # Silence this warning because _Complex is a part of C99.
+ list(APPEND compile_options "-Wdeprecated")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ # Silence this warning because _Complex is a part of C99.
list(APPEND compile_options "-fext-numeric-literals")
else()
list(APPEND compile_options "-Wno-c99-extensions")
diff --git a/libc/src/__support/CPP/span.h b/libc/src/__support/CPP/span.h
index e9e3dbf169ce027..e5073bd3c9d871a 100644
--- a/libc/src/__support/CPP/span.h
+++ b/libc/src/__support/CPP/span.h
@@ -52,6 +52,8 @@ template <typename T> class span {
LIBC_INLINE constexpr span() : span_data(nullptr), span_size(0) {}
+ LIBC_INLINE constexpr span(const span&) = default;
+
LIBC_INLINE constexpr span(pointer first, size_type count)
: span_data(first), span_size(count) {}
diff --git a/libc/test/src/setjmp/CMakeLists.txt b/libc/test/src/setjmp/CMakeLists.txt
index 049df89ba39a6f7..392230784bd993d 100644
--- a/libc/test/src/setjmp/CMakeLists.txt
+++ b/libc/test/src/setjmp/CMakeLists.txt
@@ -11,6 +11,8 @@ add_libc_unittest(
libc_setjmp_unittests
SRCS
setjmp_test.cpp
+ CXX_STANDARD
+ 20
DEPENDS
libc.src.setjmp.longjmp
libc.src.setjmp.setjmp
diff --git a/libc/test/src/setjmp/setjmp_test.cpp b/libc/test/src/setjmp/setjmp_test.cpp
index 9e5f74a1734b353..27113cd6e06311b 100644
--- a/libc/test/src/setjmp/setjmp_test.cpp
+++ b/libc/test/src/setjmp/setjmp_test.cpp
@@ -27,7 +27,7 @@ TEST(LlvmLibcSetJmpTest, SetAndJumpBack) {
// The first time setjmp is called, it should return 0.
// Subsequent calls will return the value passed to jump_back below.
if (LIBC_NAMESPACE::setjmp(buf) <= MAX_LOOP) {
- ++n;
+ n = n + 1;
jump_back(buf, n);
}
ASSERT_EQ(longjmp_called, n);
``````````
</details>
https://github.com/llvm/llvm-project/pull/125373
More information about the libc-commits
mailing list