From 2b02509f53a247784b4bb0be96061e46b53b0c4e Mon Sep 17 00:00:00 2001
From: Matt Sicker <boards@gmail.com>
Date: Sun, 27 Oct 2013 16:54:06 -0500
Subject: [PATCH] Updated a couple compiler checks to support clang.

* lib/poll.c [__clang__]: Same functionality as GCC 4.3+ for ignoring
  the (nfd < 0) tests.
* lib/verify.h [__has_feature(c_static_assert)]: Enables
  _GL_HAVE__STATIC_ASSERT when clang feature is available for C.
* lib/verify.h [__has_feature(cxx_static_assert)]: Enables
* _GL_HAVE_STATIC_ASSERT when clang feature is available for C++.
* See bug #15739
---
 lib/poll.c   |  4 ++--
 lib/verify.h | 10 ++++++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/lib/poll.c b/lib/poll.c
index 2767f5a..3b82522 100644
--- a/lib/poll.c
+++ b/lib/poll.c
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU Lesser General Public License along
    with this program; if not, see <http://www.gnu.org/licenses/>.  */
 
-/* Tell gcc not to warn about the (nfd < 0) tests, below.  */
-#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__
+/* Tell gcc (or clang) not to warn about the (nfd < 0) tests, below.  */
+#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__ || defined __clang__
 # pragma GCC diagnostic ignored "-Wtype-limits"
 #endif
 
diff --git a/lib/verify.h b/lib/verify.h
index 40b8ef5..d04e8b2 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -20,23 +20,29 @@
 #ifndef _GL_VERIFY_H
 # define _GL_VERIFY_H
 
+/* Compatibility for non-clang compilers */
+# ifndef __has_feature
+#  define __has_feature(x) 0
+# endif
 
 /* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert works as per C11.
    This is supported by GCC 4.6.0 and later, in C mode, and its use
    here generates easier-to-read diagnostics when verify (R) fails.
+   This is supported by clang when the c_static_assert feature is set.
 
    Define _GL_HAVE_STATIC_ASSERT to 1 if static_assert works as per C++11.
    This will likely be supported by future GCC versions, in C++ mode.
+   This is supported by clang when the cxx_static_assert feature is set.
 
    Use this only with GCC.  If we were willing to slow 'configure'
    down we could also use it with other compilers, but since this
    affects only the quality of diagnostics, why bother?  */
-# if (4 < __GNUC__ || (__GNUC__ == 4 && 6 <= __GNUC_MINOR__)) && !defined __cplusplus
+# if (4 < __GNUC__ || (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || __has_feature(c_static_assert)) && !defined __cplusplus
 #  define _GL_HAVE__STATIC_ASSERT 1
 # endif
 /* The condition (99 < __GNUC__) is temporary, until we know about the
    first G++ release that supports static_assert.  */
-# if (99 < __GNUC__) && defined __cplusplus
+# if ((99 < __GNUC__) || __has_feature(cxx_static_assert)) && defined __cplusplus
 #  define _GL_HAVE_STATIC_ASSERT 1
 # endif
 
-- 
1.8.4.1

