Fix clang 3 (some versions) misbehaviour for __has_attribute()

Refs: #447
Clang: https://reviews.llvm.org/rL223468 ("Modify __has_attribute so
that it only looks for GNU-style attributes")

(cherry picked from commit ffbce578c40a06491ce6585ab2d82ebb69a52d30)
This commit is contained in:
Azat Khuzhin 2017-01-30 01:58:22 +03:00 committed by Azat Khuzhin
parent 230af9f0e8
commit df01f798c2
No known key found for this signature in database
GPG Key ID: B86086848EF8686D

View File

@ -50,8 +50,18 @@
extern "C" { extern "C" {
#endif #endif
#if !defined(__has_attribute) /* __has_attribute() wrapper */
#define __has_attribute(x) 0 #ifdef __has_attribute
#define EVUTIL_HAS_ATTRIBUTE __has_attribute
#endif
/** clang 3 __has_attribute misbehaves in some versions */
#if defined(__clang__) && \
__clang__ == 1 && __clang_major__ == 3 && \
(__clang_minor__ >= 2 && __clang_minor__ <= 5)
#undef EVUTIL_HAS_ATTRIBUTE
#endif
#ifndef EVUTIL_HAS_ATTRIBUTE
#define EVUTIL_HAS_ATTRIBUTE(x) 0
#endif #endif
/* If we need magic to say "inline", get it for free internally. */ /* If we need magic to say "inline", get it for free internally. */
@ -312,7 +322,7 @@ ev_int32_t evutil_weakrand_range_(struct evutil_weakrand_state *seed, ev_int32_t
#define EVUTIL_UNLIKELY(p) (p) #define EVUTIL_UNLIKELY(p) (p)
#endif #endif
#if __has_attribute(fallthrough) #if EVUTIL_HAS_ATTRIBUTE(fallthrough)
#define EVUTIL_FALLTHROUGH __attribute__((fallthrough)) #define EVUTIL_FALLTHROUGH __attribute__((fallthrough))
#else #else
#define EVUTIL_FALLTHROUGH /* fallthrough */ #define EVUTIL_FALLTHROUGH /* fallthrough */