summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2019-11-01 14:32:05 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2019-11-01 16:58:19 +0900
commit2c889e9b05e2d2902096af02687cc6e3c7424c30 (patch)
tree8aefb17fa970b9650b777764300d6d17cd241104
parent63f70eb65160a53443ec76365e78a80948b54824 (diff)
RUBY_ATTR_ALOC_SIZE for clang
clang also supports __attribute__((__alloc_size__)) so why not use it when the compiler says it does.
-rw-r--r--include/ruby/defines.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/include/ruby/defines.h b/include/ruby/defines.h
index 8603ade340..213956c3eb 100644
--- a/include/ruby/defines.h
+++ b/include/ruby/defines.h
@@ -217,7 +217,12 @@ RUBY_SYMBOL_EXPORT_BEGIN
#if GCC_VERSION_SINCE(4,3,0)
# define RUBY_ATTR_ALLOC_SIZE(params) __attribute__ ((alloc_size params))
-#else
+#elif defined(__has_attribute)
+# if __has_attribute(alloc_size)
+# define RUBY_ATTR_ALLOC_SIZE(params) __attribute__((__alloc_size__ params))
+# endif
+#endif
+#ifndef RUBY_ATTR_ALLOC_SIZE
# define RUBY_ATTR_ALLOC_SIZE(params)
#endif