public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Addition of clang nullability qualifiers.
@ 2017-04-04  9:44 Corinna Vinschen
  0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2017-04-04  9:44 UTC (permalink / raw)
  To: newlib-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=81c121c48739df247ade660659cd6672a9a2c7dd

commit 81c121c48739df247ade660659cd6672a9a2c7dd
Author: pfg <pfg@FreeBSD.org>
Date:   Tue Apr 4 09:04:55 2017 +0200

    Addition of clang nullability qualifiers.
    
    Add two new qualifiers for use by the static checkers:
    
    _Nonnull
    The _Nonnull nullability qualifier indicates that null is not a meaningful
    value for a value of the _Nonnull pointer type.
    
    _Nullable
    The _Nullable nullability qualifier indicates that a value of the
    _Nullable pointer type can be null.
    
    These were introduced in Clang 3.7. For more information, see:
    http://clang.llvm.org/docs/AttributeReference.html#nonnull
    
    We add these now without using them so that the GCC ports have time to
    pick up the header change.
    
    Hinted by:	Android Bionic libc [1]
    Also seen in:	Apple's Libc-1158.20.4
    
    [1]
    https://github.com/android/platform_bionic/commit/baa2a973bd776a51bb05a8590ab05d86eea7b321

Diff:
---
 newlib/libc/include/sys/cdefs.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/newlib/libc/include/sys/cdefs.h b/newlib/libc/include/sys/cdefs.h
index 68172ad..ad23232 100644
--- a/newlib/libc/include/sys/cdefs.h
+++ b/newlib/libc/include/sys/cdefs.h
@@ -645,6 +645,14 @@
 #endif
 
 /*
+ * Nullability qualifiers: currently only supported by Clang.
+ */
+#if !(defined(__clang__) && __has_feature(nullability))
+#define	_Nonnull
+#define	_Nullable
+#endif
+
+/*
  * Type Safety Checking
  *
  * Clang provides additional attributes to enable checking type safety


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [newlib-cygwin] Addition of clang nullability qualifiers.
@ 2017-04-04  9:44 Corinna Vinschen
  0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2017-04-04  9:44 UTC (permalink / raw)
  To: newlib-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=7b07f11b1fc79224afaa8967a356796610bf82bf

commit 7b07f11b1fc79224afaa8967a356796610bf82bf
Author: pfg <pfg@FreeBSD.org>
Date:   Tue Apr 4 09:04:57 2017 +0200

    Addition of clang nullability qualifiers.
    
    For consistency with the qualifiers added in r310977, define a new
    qualifier _Null_unspecified which is also defined in clang 3.7+.
    
    Add two new macros:
    __NULLABILITY_PRAGMA_PUSH
    __NULLABILITY_PRAGMA_POP
    
    These are for use in headers when we want avoid noisy warnings if
    some pointers are left without nullability annotations.
    
    These are added with way ahead of their first use to teach the GCC
    ports headers of their existance before their first use.

Diff:
---
 newlib/libc/include/sys/cdefs.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/newlib/libc/include/sys/cdefs.h b/newlib/libc/include/sys/cdefs.h
index 679425a..fa1692c 100644
--- a/newlib/libc/include/sys/cdefs.h
+++ b/newlib/libc/include/sys/cdefs.h
@@ -634,6 +634,13 @@
 #if !(defined(__clang__) && __has_feature(nullability))
 #define	_Nonnull
 #define	_Nullable
+#define	_Null_unspecified
+#define	__NULLABILITY_PRAGMA_PUSH
+#define	__NULLABILITY_PRAGMA_POP
+#else
+#define	__NULLABILITY_PRAGMA_PUSH _Pragma("clang diagnostic push")	\
+	_Pragma("clang diagnostic ignored \"-Wnullability-completeness\"")
+#define	__NULLABILITY_PRAGMA_POP _Pragma("clang diagnostic pop")
 #endif
 
 /*


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-04  9:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-04  9:44 [newlib-cygwin] Addition of clang nullability qualifiers Corinna Vinschen
  -- strict thread matches above, loose matches on Subject: below --
2017-04-04  9:44 Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).