From f8638ee2c1a020567221a180ff1c9328d2ade6a9 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 4 Oct 2017 12:49:35 +1300 Subject: [PATCH] Make XAPIAN_NONNULL a no-op for GCC 4.8 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit It seems to give false positive warnings: In file included from ./common/submatch.h:24:0, from matcher/multimatch.h:27, from matcher/multimatch.cc:28: ./include/xapian/intrusive_ptr.h: In instantiation of ‘Xapian::Internal::intrusive_ptr_nonnull& Xapian::Internal::intrusive_ptr_nonnull::operator=(T*) [with T = Xapian::MSet::Internal]’: matcher/multimatch.cc:318:16: required from here ./include/xapian/intrusive_ptr.h:224:9: error: null argument where non-null required (argument 1) [-Werror=nonnull] this_type(rhs).swap(*this); ^ --- xapian-core/include/xapian/attributes.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xapian-core/include/xapian/attributes.h b/xapian-core/include/xapian/attributes.h index b18efc4a6..74a8261be 100644 --- a/xapian-core/include/xapian/attributes.h +++ b/xapian-core/include/xapian/attributes.h @@ -45,9 +45,13 @@ // __attribute__((__pure__)) is available from GCC 2.96 onwards. # define XAPIAN_PURE_FUNCTION __attribute__((__pure__)) // __attribute__((__nothrow__)) is available from GCC 3.3 onwards. -// __attribute__((__nonnull__(a,b,c))) is also available from GCC 3.3 onwards. # if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) # define XAPIAN_NOTHROW(D) D XAPIAN_NOEXCEPT __attribute__((__nothrow__)) +# endif +// __attribute__((__nonnull__(a,b,c))) is also available from GCC 3.3 onwards, +// but it seems to be buggy in GCC 4.8 so only enable it for versions after +// that. Always enable for clang, which currently pretends to be GCC 4.2. +# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 8) || defined __clang__ # define XAPIAN_NONNULL(LIST) __attribute__((__nonnull__ LIST)) # endif #else -- 2.11.4.GIT