Skip to content

Commit c8e7a87

Browse files
thesamesamtstellar
authored andcommitted
[CMake] Fix -Wstrict-prototypes
Fixes warnings (or errors, if someone injects -Werror in their build system, which happens in fact with some folks vendoring LLVM too) with Clang 16: ``` +/var/tmp/portage.notmp/portage/sys-devel/llvm-15.0.4/work/llvm_build-abi_x86_64.amd64/CMakeFiles/CMakeTmp/src.c:3:9: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes] -/var/tmp/portage.notmp/portage/sys-devel/llvm-14.0.4/work/llvm_build-abi_x86_64.amd64/CMakeFiles/CMakeTmp/src.c:3:9: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes] int main() {return 0;} ^ void ``` Differential Revision: https://reviews.llvm.org/D137503 (cherry picked from commit 32a2af4)
1 parent 5c68a1c commit c8e7a87

File tree

14 files changed

+26
-25
lines changed

14 files changed

+26
-25
lines changed

compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function(darwin_test_archs os valid_archs)
116116
if(NOT TEST_COMPILE_ONLY)
117117
message(STATUS "Finding valid architectures for ${os}...")
118118
set(SIMPLE_C ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/src.c)
119-
file(WRITE ${SIMPLE_C} "#include <stdio.h>\nint main() { printf(__FILE__); return 0; }\n")
119+
file(WRITE ${SIMPLE_C} "#include <stdio.h>\nint main(void) { printf(__FILE__); return 0; }\n")
120120

121121
set(os_linker_flags)
122122
foreach(flag ${DARWIN_${os}_LINK_FLAGS})

compiler-rt/cmake/config-ix.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ set(COMPILER_RT_SUPPORTED_ARCH)
209209
# runtime libraries supported by our current compilers cross-compiling
210210
# abilities.
211211
set(SIMPLE_SOURCE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/simple.cc)
212-
file(WRITE ${SIMPLE_SOURCE} "#include <stdlib.h>\n#include <stdio.h>\nint main() { printf(\"hello, world\"); }\n")
212+
file(WRITE ${SIMPLE_SOURCE} "#include <stdlib.h>\n#include <stdio.h>\nint main(void) { printf(\"hello, world\"); }\n")
213213

214214
# Detect whether the current target platform is 32-bit or 64-bit, and setup
215215
# the correct commandline flags needed to attempt to target 32-bit and 64-bit.

compiler-rt/lib/builtins/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ else ()
745745
SOURCE "#if !(__ARM_FP & 0x8)
746746
#error No double-precision support!
747747
#endif
748-
int main() { return 0; }")
748+
int main(void) { return 0; }")
749749
if(NOT COMPILER_RT_HAS_${arch}_VFP_DP)
750750
list(REMOVE_ITEM ${arch}_SOURCES ${arm_Thumb1_VFPv2_DP_SOURCES})
751751
endif()

libcxx/cmake/config-ix.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
9494
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror=unknown-pragmas")
9595
check_c_source_compiles("
9696
#pragma comment(lib, \"c\")
97-
int main() { return 0; }
97+
int main(void) { return 0; }
9898
" C_SUPPORTS_COMMENT_LIB_PRAGMA)
9999
cmake_pop_check_state()
100100
endif()

libcxxabi/cmake/config-ix.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
7777
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror=unknown-pragmas")
7878
check_c_source_compiles("
7979
#pragma comment(lib, \"c\")
80-
int main() { return 0; }
80+
int main(void) { return 0; }
8181
" C_SUPPORTS_COMMENT_LIB_PRAGMA)
8282
cmake_pop_check_state()
8383
endif()

libunwind/cmake/config-ix.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
8585
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror=unknown-pragmas")
8686
check_c_source_compiles("
8787
#pragma comment(lib, \"c\")
88-
int main() { return 0; }
88+
int main(void) { return 0; }
8989
" C_SUPPORTS_COMMENT_LIB_PRAGMA)
9090
cmake_pop_check_state()
9191
endif()

lldb/tools/debugserver/source/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ check_c_source_compiles(
9595
#else
9696
#error Not building for ARM64
9797
#endif
98-
int main() { return 0; }
98+
int main(void) { return 0; }
9999
"
100100
BUILDING_FOR_ARM64_OSX
101101
)

llvm/cmake/config-ix.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ if(APPLE)
7171
CHECK_C_SOURCE_COMPILES("
7272
static const char *__crashreporter_info__ = 0;
7373
asm(\".desc ___crashreporter_info__, 0x10\");
74-
int main() { return 0; }"
74+
int main(void) { return 0; }"
7575
HAVE_CRASHREPORTER_INFO)
7676
endif()
7777

llvm/cmake/modules/FindFFI.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ if(FFI_LIBRARIES)
4545
struct ffi_cif;
4646
typedef struct ffi_cif ffi_cif;
4747
void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue);
48-
int main() { ffi_call(0, 0, 0, 0); }"
48+
int main(void) { ffi_call(0, 0, 0, 0); }"
4949
HAVE_FFI_CALL)
5050
cmake_pop_check_state()
5151
endif()

llvm/cmake/modules/FindTerminfo.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if(Terminfo_LIBRARIES)
2020
list(APPEND CMAKE_REQUIRED_LIBRARIES ${Terminfo_LIBRARIES})
2121
check_c_source_compiles("
2222
int setupterm(char *term, int filedes, int *errret);
23-
int main() { return setupterm(0, 0, 0); }"
23+
int main(void) { return setupterm(0, 0, 0); }"
2424
Terminfo_LINKABLE)
2525
cmake_pop_check_state()
2626
endif()

0 commit comments

Comments
 (0)