Skip to content

Commit e6f36ba

Browse files
committed
[libc++] Enable -Wmissing-prototypes
1 parent aaa0dd2 commit e6f36ba

File tree

9 files changed

+25
-4
lines changed

9 files changed

+25
-4
lines changed

libcxx/src/charconv.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
1818

1919
namespace __itoa {
2020

21+
_LIBCPP_DIAGNOSTIC_PUSH
22+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-prototypes")
23+
// These functions exist for ABI compatibility, so we don't ever want a declaration.
2124
_LIBCPP_EXPORTED_FROM_ABI char* __u32toa(uint32_t value, char* buffer) noexcept { return __base_10_u32(buffer, value); }
22-
2325
_LIBCPP_EXPORTED_FROM_ABI char* __u64toa(uint64_t value, char* buffer) noexcept { return __base_10_u64(buffer, value); }
26+
_LIBCPP_DIAGNOSTIC_POP
2427

2528
} // namespace __itoa
2629

libcxx/src/filesystem/int128_builtins.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <__config>
1717
#include <climits>
1818

19+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-prototypes") // See the FIXME above
20+
1921
#if _LIBCPP_HAS_INT128
2022

2123
extern "C" __attribute__((no_sanitize("undefined"))) _LIBCPP_EXPORTED_FROM_ABI __int128_t

libcxx/src/include/from_chars_floating_point.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ struct __exponent_result {
193193
// __offset, 0, false. This allows using the results unconditionally, the
194194
// __present is important for the scientific notation, where the value is
195195
// mandatory.
196-
__exponent_result __parse_exponent(const char* __input, size_t __n, size_t __offset, char __marker) {
196+
static __exponent_result __parse_exponent(const char* __input, size_t __n, size_t __offset, char __marker) {
197197
if (__offset + 1 < __n && // an exponent always needs at least one digit.
198198
std::tolower(__input[__offset]) == __marker && //
199199
!std::isspace(__input[__offset + 1]) // leading whitespace is not allowed.
@@ -213,7 +213,7 @@ __exponent_result __parse_exponent(const char* __input, size_t __n, size_t __off
213213
}
214214

215215
// Here we do this operation as int64 to avoid overflow.
216-
int32_t __merge_exponents(int64_t __fractional, int64_t __exponent, int __max_biased_exponent) {
216+
static int32_t __merge_exponents(int64_t __fractional, int64_t __exponent, int __max_biased_exponent) {
217217
int64_t __sum = __fractional + __exponent;
218218

219219
if (__sum > __max_biased_exponent)

libcxx/src/legacy_pointer_safety.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@
1515

1616
_LIBCPP_BEGIN_NAMESPACE_STD
1717

18+
_LIBCPP_DIAGNOSTIC_PUSH
19+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-prototypes")
20+
// These functions exist for ABI compatibility, so we don't ever want a declaration.
1821
_LIBCPP_EXPORTED_FROM_ABI void declare_reachable(void*) {}
1922
_LIBCPP_EXPORTED_FROM_ABI void declare_no_pointers(char*, size_t) {}
2023
_LIBCPP_EXPORTED_FROM_ABI void undeclare_no_pointers(char*, size_t) {}
2124
_LIBCPP_EXPORTED_FROM_ABI void* __undeclare_reachable(void* p) { return p; }
25+
_LIBCPP_DIAGNOSTIC_POP
2226

2327
_LIBCPP_END_NAMESPACE_STD

libcxxabi/src/cxa_personality.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
#include "private_typeinfo.h"
2323
#include "unwind.h"
2424

25+
// The functions defined in this file are magic functions called only by the compiler.
26+
#ifdef __clang__
27+
# pragma clang diagnostic ignored "-Wmissing-prototypes"
28+
#endif
29+
2530
// TODO: This is a temporary workaround for libc++abi to recognize that it's being
2631
// built against LLVM's libunwind. LLVM's libunwind started reporting _LIBUNWIND_VERSION
2732
// in LLVM 15 -- we can remove this workaround after shipping LLVM 17. Once we remove

libcxxabi/src/private_typeinfo.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,10 @@ bool __pointer_to_member_type_info::can_catch_nested(
832832
#pragma clang diagnostic ignored "-Wmissing-field-initializers"
833833
#endif
834834

835+
#pragma GCC diagnostic push
836+
// __dynamic_cast is called by the compiler, so there is no prototype
837+
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
838+
835839
// __dynamic_cast
836840

837841
// static_ptr: pointer to an object of type static_type; nonnull, and since the
@@ -954,6 +958,8 @@ __dynamic_cast(const void *static_ptr, const __class_type_info *static_type,
954958
return const_cast<void*>(dst_ptr);
955959
}
956960

961+
#pragma GCC diagnostic push
962+
957963
#ifdef __clang__
958964
#pragma clang diagnostic pop
959965
#endif

libunwind/src/UnwindLevel1.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except
181181
}
182182
return _URC_NO_REASON;
183183
}
184-
extern int __unw_step_stage2(unw_cursor_t *);
185184

186185
#if defined(_LIBUNWIND_USE_GCS)
187186
// Enable the GCS target feature to permit gcspop instructions to be used.

libunwind/src/libunwind_ext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ extern "C" {
2626
extern int __unw_getcontext(unw_context_t *);
2727
extern int __unw_init_local(unw_cursor_t *, unw_context_t *);
2828
extern int __unw_step(unw_cursor_t *);
29+
extern int __unw_step_stage2(unw_cursor_t *);
2930
extern int __unw_get_reg(unw_cursor_t *, unw_regnum_t, unw_word_t *);
3031
extern int __unw_get_fpreg(unw_cursor_t *, unw_regnum_t, unw_fpreg_t *);
3132
extern int __unw_set_reg(unw_cursor_t *, unw_regnum_t, unw_word_t);

runtimes/cmake/Modules/WarningFlags.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ function(cxx_add_warning_flags target enable_werror enable_pedantic)
2525
-Wformat-nonliteral
2626
-Wzero-length-array
2727
-Wdeprecated-redundant-constexpr-static-def
28+
-Wmissing-prototypes
2829
)
2930

3031
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")

0 commit comments

Comments
 (0)