From 4020bc9376eb77d8b6493d98bf9dc6c5b03e41dc Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 20 Jan 2025 13:16:57 -0500 Subject: Use "system" include type for all dependencies and add header test Things get confused when these flags differ across projects, so universally use "system" for external dependencies and test for header warnings only in the project that owns them. --- test/headers/.clang-tidy | 15 +++++++++++++++ test/headers/meson.build | 27 +++++++++++++++++++++++++++ test/headers/test_headers.c | 13 +++++++++++++ test/meson.build | 6 ++++++ 4 files changed, 61 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..a42a718 --- /dev/null +++ b/test/headers/.clang-tidy @@ -0,0 +1,15 @@ +# Copyright 2020-2024 David Robillard +# SPDX-License-Identifier: 0BSD OR ISC + +Checks: > + *, + -altera-*, + -llvmlibc-*, +CheckOptions: + - key: readability-function-cognitive-complexity.Threshold + value: '1' + - key: readability-identifier-length.IgnoredParameterNames + value: '^(a)|(b)|(ui)|(i)$' +WarningsAsErrors: '*' +HeaderFilterRegex: '.*' +FormatStyle: file diff --git a/test/headers/meson.build b/test/headers/meson.build new file mode 100644 index 0000000..4415de1 --- /dev/null +++ b/test/headers/meson.build @@ -0,0 +1,27 @@ +# Copyright 2020-2025 David Robillard +# SPDX-License-Identifier: 0BSD OR ISC + +header_c_suppressions = [] + +if get_option('warning_level') == 'everything' + if cc.get_id() == 'clang' + if not meson.is_cross_build() + header_c_suppressions += ['-Wno-poison-system-directories'] + endif + 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: lilv_dep, + ), + suite: 'unit', +) diff --git a/test/headers/test_headers.c b/test/headers/test_headers.c new file mode 100644 index 0000000..b0d4aa5 --- /dev/null +++ b/test/headers/test_headers.c @@ -0,0 +1,13 @@ +// Copyright 2022-2025 David Robillard +// SPDX-License-Identifier: ISC + +#include // IWYU pragma: keep + +#ifdef __GNUC__ +__attribute__((const)) +#endif +int +main(void) +{ + return 0; +} diff --git a/test/meson.build b/test/meson.build index e260f37..eec78b5 100644 --- a/test/meson.build +++ b/test/meson.build @@ -1,6 +1,12 @@ # Copyright 2020-2022 David Robillard # SPDX-License-Identifier: 0BSD OR ISC +################### +# Header Warnings # +################### + +subdir('headers') + ############## # Test Setup # ############## -- cgit v1.2.1