Work around LLVM bug 16404, which is still not fixed.
https://llvm.org/bugs/show_bug.cgi?id=16404
Problem reported by Nelson H. F. Beebe.
* lib/glob.c, lib/intprops.h, lib/xalloc-oversized.h (__has_builtin):
Remove.
* lib/glob.c (size_add_wrapv):
* lib/intprops.h (_GL_HAS_BUILTIN_OVERFLOW, _GL_HAS_BUILTIN_OVERFLOW_P):
* lib/xalloc-oversized.h (xalloc_oversized):
Do not use overflow builtins if Clang.
2017-01-06 Paul Eggert <eggert@cs.ucla.edu>
+ glob, intprops, xalloc: work around Clang bug
+ Work around LLVM bug 16404, which is still not fixed.
+ https://llvm.org/bugs/show_bug.cgi?id=16404
+ Problem reported by Nelson H. F. Beebe.
+ * lib/glob.c, lib/intprops.h, lib/xalloc-oversized.h (__has_builtin):
+ Remove.
+ * lib/glob.c (size_add_wrapv):
+ * lib/intprops.h (_GL_HAS_BUILTIN_OVERFLOW, _GL_HAS_BUILTIN_OVERFLOW_P):
+ * lib/xalloc-oversized.h (xalloc_oversized):
+ Do not use overflow builtins if Clang.
+
dfa: fix 'return' typo
Problem reported by Nelson H. F. Beebe.
* lib/dfa.c (merge): Fix typo that Sun compilers rejected.
((void) (buf), (void) (len), (void) (newlen), (void) (avar), (void *) 0)
#endif
-#ifndef __has_builtin
-# define __has_builtin(x) 0
-#endif
-
/* Set *R = A + B. Return true if the answer is mathematically
incorrect due to overflow; in this case, *R is the low order
bits of the correct answer.. */
static bool
size_add_wrapv (size_t a, size_t b, size_t *r)
{
-#if 5 <= __GNUC__ || __has_builtin (__builtin_add_overflow)
+#if 5 <= __GNUC__
return __builtin_add_overflow (a, b, r);
#else
*r = a + b;
#include <limits.h>
#include <verify.h>
-#ifndef __has_builtin
-# define __has_builtin(x) 0
-#endif
-
/* Return a value with the common real type of E and V and the value of V. */
#define _GL_INT_CONVERT(e, v) (0 * (e) + (v))
: (max) >> (b) < (a))
/* True if __builtin_add_overflow (A, B, P) works when P is non-null. */
-#define _GL_HAS_BUILTIN_OVERFLOW \
- (5 <= __GNUC__ || __has_builtin (__builtin_add_overflow))
+#define _GL_HAS_BUILTIN_OVERFLOW (5 <= __GNUC__)
/* True if __builtin_add_overflow_p (A, B, C) works. */
-#define _GL_HAS_BUILTIN_OVERFLOW_P \
- (7 <= __GNUC__ || __has_builtin (__builtin_add_overflow_p))
+#define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__)
/* The _GL*_OVERFLOW macros have the same restrictions as the
*_RANGE_OVERFLOW macros, except that they do not assume that operands
#include <stddef.h>
#include <stdint.h>
-/* Default for (non-Clang) compilers that lack __has_builtin. */
-#ifndef __has_builtin
-# define __has_builtin(x) 0
-#endif
-
/* True if N * S would overflow in a size_t calculation,
or would generate a value larger than PTRDIFF_MAX.
This expands to a constant expression if N and S are both constants.
positive and N must be nonnegative. This is a macro, not a
function, so that it works correctly even when SIZE_MAX < N. */
-#if 7 <= __GNUC__ || __has_builtin (__builtin_add_overflow_p)
+#if 7 <= __GNUC__
# define xalloc_oversized(n, s) \
__builtin_mul_overflow_p (n, s, (__xalloc_count_type) 1)
-#elif ((5 <= __GNUC__ \
- || (__has_builtin (__builtin_mul_overflow) \
- && __has_builtin (__builtin_constant_p))) \
- && !__STRICT_ANSI__)
+#elif 5 <= __GNUC__ && !__STRICT_ANSI__
# define xalloc_oversized(n, s) \
(__builtin_constant_p (n) && __builtin_constant_p (s) \
? __xalloc_oversized (n, s) \