summaryrefslogtreecommitdiff
path: root/include/ruby/defines.h
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-15 02:35:20 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-15 02:35:20 +0000
commit8f745a2fab4f5aacb07db191a8390677a685003e (patch)
tree0340033547873a093d4d062110d9806fcf1f5224 /include/ruby/defines.h
parentdf9a70900a7380bc9b42b12ab90cf182988bcd45 (diff)
more support for NORETURN
Before this NORETURN was checked only for __attribute__ or __declspec, but nowadays other ways are there to tell compilers that a function never returns. Take them into account. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include/ruby/defines.h')
-rw-r--r--include/ruby/defines.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/include/ruby/defines.h b/include/ruby/defines.h
index 322df4c6d2..9a2cd34caf 100644
--- a/include/ruby/defines.h
+++ b/include/ruby/defines.h
@@ -29,10 +29,6 @@ extern "C" {
#ifndef PUREFUNC
# define PUREFUNC(x) x
#endif
-#define NORETURN_STYLE_NEW 1
-#ifndef NORETURN
-# define NORETURN(x) x
-#endif
#ifndef DEPRECATED
# define DEPRECATED(x) x
#endif
@@ -390,6 +386,17 @@ void rb_ia64_flushrs(void);
#define RUBY_ALIGNOF(x) ((size_t)offsetof(struct { char f1; type f2; }, f2))
#endif
+#define NORETURN_STYLE_NEW 1
+#ifdef NORETURN
+/* OK, take that definition */
+#elif defined(__cplusplus) && (__cplusplus >= 201103L)
+#define NORETURN(x) [[ noreturn ]] x
+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
+#define NORETURN(x) _Noreturn x
+#else
+#define NORETURN(x) x
+#endif
+
RUBY_SYMBOL_EXPORT_END
#if defined(__cplusplus)