From ff15f7a90cc7aa86ad46ae244319f152980469ed Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 18 Dec 2022 00:45:55 -0500 Subject: tests: fix test that has source code incompatible with modern C Delayed until clang 16, -Werror=incompatible-function-pointer-types is the default. GCC 14 is "likely to do the same". See https://wiki.gentoo.org/wiki/Modern_C_porting --- test cases/common/94 threads/meson.build | 5 +++++ test cases/common/94 threads/threadprog.c | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/test cases/common/94 threads/meson.build b/test cases/common/94 threads/meson.build index 1fbb15a..6a939ff 100644 --- a/test cases/common/94 threads/meson.build +++ b/test cases/common/94 threads/meson.build @@ -1,6 +1,11 @@ project('threads', 'cpp', 'c', default_options : ['cpp_std=c++11']) +cc = meson.get_compiler('c') +if cc.has_function_attribute('unused') + add_project_arguments('-DHAVE_UNUSED', language: 'c') +endif + threaddep = dependency('threads') test('cppthreadtest', diff --git a/test cases/common/94 threads/threadprog.c b/test cases/common/94 threads/threadprog.c index 7bfb7c4..19130d5 100644 --- a/test cases/common/94 threads/threadprog.c +++ b/test cases/common/94 threads/threadprog.c @@ -22,7 +22,13 @@ int main(void) { #include #include -void* main_func(void) { +#ifdef HAVE_UNUSED + #define UNUSED_ATTR __attribute__((unused)) +#else + #define UNUSED_ATTR +#endif + +void* main_func(void UNUSED_ATTR *arg) { printf("Printing from a thread.\n"); return NULL; } -- cgit v1.1