aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-12-18 00:45:55 -0500
committerNirbheek Chauhan <nirbheek@centricular.com>2023-02-06 23:37:24 +0530
commit15f8d4c3332fd5c8ce9c67379ef3d1bb60be1566 (patch)
treee5a4b90fcd0510cc564f17fd38deebd2a66cb66a
parentcade1adc5feea5cb838a0d866d7b0151d8b647ad (diff)
downloadmeson-15f8d4c3332fd5c8ce9c67379ef3d1bb60be1566.zip
meson-15f8d4c3332fd5c8ce9c67379ef3d1bb60be1566.tar.gz
meson-15f8d4c3332fd5c8ce9c67379ef3d1bb60be1566.tar.bz2
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
-rw-r--r--test cases/common/94 threads/meson.build5
-rw-r--r--test cases/common/94 threads/threadprog.c8
2 files changed, 12 insertions, 1 deletions
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<pthread.h>
#include<stdio.h>
-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;
}