Skip to content

Commit 648981f

Browse files
authored
[libc] Build with -Wdeprecated, fix some warnings (llvm#125373)
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.
1 parent 312055d commit 648981f

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

libc/cmake/modules/LLVMLibCCompileOptionRules.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,9 @@ function(_get_common_compile_options output_var flags)
179179
endif()
180180
list(APPEND compile_options "-Wconversion")
181181
list(APPEND compile_options "-Wno-sign-conversion")
182-
# Silence this warning because _Complex is a part of C99.
182+
list(APPEND compile_options "-Wdeprecated")
183183
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
184+
# Silence this warning because _Complex is a part of C99.
184185
list(APPEND compile_options "-fext-numeric-literals")
185186
else()
186187
list(APPEND compile_options "-Wno-c99-extensions")

libc/src/__support/CPP/span.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include <stddef.h> // For size_t
1212

13-
#include "array.h" // For array
13+
#include "array.h" // For array
1414
#include "src/__support/macros/config.h"
1515
#include "type_traits.h" // For remove_cv_t, enable_if_t, is_same_v, is_const_v
1616

@@ -52,6 +52,8 @@ template <typename T> class span {
5252

5353
LIBC_INLINE constexpr span() : span_data(nullptr), span_size(0) {}
5454

55+
LIBC_INLINE constexpr span(const span &) = default;
56+
5557
LIBC_INLINE constexpr span(pointer first, size_type count)
5658
: span_data(first), span_size(count) {}
5759

libc/test/src/setjmp/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ add_libc_unittest(
1111
libc_setjmp_unittests
1212
SRCS
1313
setjmp_test.cpp
14+
CXX_STANDARD
15+
20
1416
DEPENDS
1517
libc.src.setjmp.longjmp
1618
libc.src.setjmp.setjmp

libc/test/src/setjmp/setjmp_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ TEST(LlvmLibcSetJmpTest, SetAndJumpBack) {
2727
// The first time setjmp is called, it should return 0.
2828
// Subsequent calls will return the value passed to jump_back below.
2929
if (LIBC_NAMESPACE::setjmp(buf) <= MAX_LOOP) {
30-
++n;
30+
n = n + 1;
3131
jump_back(buf, n);
3232
}
3333
ASSERT_EQ(longjmp_called, n);

0 commit comments

Comments
 (0)