From 117ae267046ed564684793270b82767c585c724b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 9 Jan 2024 21:09:56 -0500 Subject: Avoid regressions in clang nullability checks Clang 15 (and still as of 16) lost the ability to understand null checks in conditionals, which is supposed to suppress these warnings. For now, work around some, and suppress others. The suppression boilerplate here is noisy and ugly, and hopefully temporary. It should be removed once the issue is fixed in clang. See https://github.com/llvm/llvm-project/issues/63018 --- src/warnings.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/warnings.h (limited to 'src/warnings.h') diff --git a/src/warnings.h b/src/warnings.h new file mode 100644 index 00000000..4fdec095 --- /dev/null +++ b/src/warnings.h @@ -0,0 +1,23 @@ +// Copyright 2019-2024 David Robillard +// SPDX-License-Identifier: ISC + +#ifndef SERD_SRC_WARNINGS_H +#define SERD_SRC_WARNINGS_H + +#if defined(__clang__) + +/// Clang 15 null checking regressed, so we need to suppress it sometimes +# define SERD_DISABLE_NULL_WARNINGS \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wnullable-to-nonnull-conversion\"") + +# define SERD_RESTORE_WARNINGS _Pragma("clang diagnostic pop") + +#else + +# define SERD_DISABLE_NULL_WARNINGS +# define SERD_RESTORE_WARNINGS + +#endif + +#endif // SERD_SRC_WARNINGS_H -- cgit v1.2.1