From b725923951d77f5c6792c2797f89179267c58c9c Mon Sep 17 00:00:00 2001 From: Yusuke Suzuki Date: Thu, 2 Oct 2014 03:38:02 +0900 Subject: Fix __alloc_size__ availability detection (Clang) Since __clang_major__/__clang_minor__ etc. are vendor dependent values, we cannot implement the feature detection based on it. For example, Apple clang versioning is different from the FreeBSD clang. (At this time, Apple clang version is "6.0 (clang-600.0.51)" and __clang_major__ is 6.) Instead of this, we can use the clang feature detection macro, __has_attribute. * include/gc_config_macros.h (GC_ATTR_ALLOC_SIZE): Replace predefined __clang_major/minor__ testing with __has_attribute() one (in case of clang). --- include/gc_config_macros.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/include/gc_config_macros.h b/include/gc_config_macros.h index 13f7e77a..d6da7ca2 100644 --- a/include/gc_config_macros.h +++ b/include/gc_config_macros.h @@ -242,14 +242,17 @@ #ifndef GC_ATTR_ALLOC_SIZE /* 'alloc_size' attribute improves __builtin_object_size correctness. */ /* Only single-argument form of 'alloc_size' attribute is used. */ -# if defined(__GNUC__) && (__GNUC__ > 4 \ - || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3 && !defined(__ICC)) \ - || __clang_major__ > 3 \ - || (__clang_major__ == 3 && __clang_minor__ >= 2 \ - && (__clang_minor__ != 5 || __clang_patchlevel__ != 0))) +# ifdef __clang__ +# if __has_attribute(__alloc_size__) +# define GC_ATTR_ALLOC_SIZE(argnum) __attribute__((__alloc_size__(argnum))) +# else +# define GC_ATTR_ALLOC_SIZE(argnum) /* empty */ +# endif +# elif __GNUC__ > 4 \ + || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3 && !defined(__ICC)) # define GC_ATTR_ALLOC_SIZE(argnum) __attribute__((__alloc_size__(argnum))) # else -# define GC_ATTR_ALLOC_SIZE(argnum) +# define GC_ATTR_ALLOC_SIZE(argnum) /* empty */ # endif #endif -- cgit v1.2.1