From 07248d1c3ea7cb071aafddebf0ba98221baa08d0 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 10 Dec 2022 11:04:10 -0500 Subject: Test header for warnings more strictly --- test/headers/.clang-tidy | 10 ++++++++++ test/headers/meson.build | 43 +++++++++++++++++++++++++++++++++++++++++++ test/headers/test_headers.c | 13 +++++++++++++ test/meson.build | 6 ++++++ 4 files changed, 72 insertions(+) create mode 100644 test/headers/.clang-tidy create mode 100644 test/headers/meson.build create mode 100644 test/headers/test_headers.c (limited to 'test') diff --git a/test/headers/.clang-tidy b/test/headers/.clang-tidy new file mode 100644 index 0000000..924f1d5 --- /dev/null +++ b/test/headers/.clang-tidy @@ -0,0 +1,10 @@ +# Copyright 2020-2022 David Robillard +# SPDX-License-Identifier: 0BSD OR ISC + +Checks: > + *, + -altera-*, + -llvmlibc-*, +WarningsAsErrors: '*' +HeaderFilterRegex: '.*/sratom\.h' +FormatStyle: file diff --git a/test/headers/meson.build b/test/headers/meson.build new file mode 100644 index 0000000..aed2e43 --- /dev/null +++ b/test/headers/meson.build @@ -0,0 +1,43 @@ +# Copyright 2020-2022 David Robillard +# SPDX-License-Identifier: 0BSD OR ISC + +header_c_suppressions = [] + +if get_option('strict') + if cc.get_id() == 'clang' + header_c_suppressions += [ + '-Wno-cast-align', # LV2 + '-Wno-cast-qual', # LV2 + '-Wno-declaration-after-statement', # LV2 + ] + elif cc.get_id() == 'gcc' + header_c_suppressions += [ + '-Wno-cast-align', # LV2 + '-Wno-cast-qual', # LV2 + '-Wno-padded', # Serd + '-Wno-sign-conversion', # LV2 + '-Wno-unused-const-variable', # Serd + ] + elif cc.get_id() == 'msvc' + header_c_suppressions += [ + '/wd4820', # padding added after construct + ] + endif +endif + +if cc.get_id() == 'clang' + header_c_suppressions += [ + '-Wno-nullability-extension', + ] +endif + +test( + 'headers', + executable( + 'test_headers', + files('test_headers.c'), + c_args: header_c_suppressions, + dependencies: [sratom_dep], + ), + suite: 'unit', +) diff --git a/test/headers/test_headers.c b/test/headers/test_headers.c new file mode 100644 index 0000000..f6b110f --- /dev/null +++ b/test/headers/test_headers.c @@ -0,0 +1,13 @@ +// Copyright 2022 David Robillard +// SPDX-License-Identifier: ISC + +#include "sratom/sratom.h" // IWYU pragma: keep + +#ifdef __GNUC__ +__attribute__((const)) +#endif +int +main(void) +{ + return 0; +} diff --git a/test/meson.build b/test/meson.build index d95c259..841b8af 100644 --- a/test/meson.build +++ b/test/meson.build @@ -23,6 +23,12 @@ if get_option('strict') endif endif +################### +# Header Warnings # +################### + +subdir('headers') + ############## # Unit Tests # ############## -- cgit v1.2.1