[前][次][番号順一覧][スレッド一覧]

ruby-changes:60790

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Thu, 16 Apr 2020 17:33:58 +0900 (JST)
Subject: [ruby-changes:60790] 3eb05a8071 (master): fix compiler error on gcc 4.x

https://git.ruby-lang.org/ruby.git/commit/?id=3eb05a8071

From 3eb05a8071815cfbb2500e624ad675f324cc72fa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?=
 <shyouhei@r...>
Date: Thu, 16 Apr 2020 17:00:13 +0900
Subject: fix compiler error on gcc 4.x

It seems gcc prior to 5 suffered from preprocessor bug.  We have to
provide workarounds.

See https://github.com/ruby/ruby/runs/591138012

----

Here is something interesting.  According to C99, strictly speaking,
the gcc behaviour was in fact legal(!) and everything else were
wrong.  This was not a bug of gcc, rather a bug of the ISO C Standard.
This defect was reported to the committee as DR#412, and fixed
accordingly.  All tested compilers now conform C17's updated
preprocessor description.

See http://www.open-std.org/JTC1/SC22/WG14/www/docs/dr_412.htm

diff --git a/include/ruby/3/has/attribute.h b/include/ruby/3/has/attribute.h
index 39ce321..8fa7025 100644
--- a/include/ruby/3/has/attribute.h
+++ b/include/ruby/3/has/attribute.h
@@ -24,14 +24,13 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/3/has/attribute.h#L24
 #include "ruby/3/compiler_since.h"
 #include "ruby/3/token_paste.h"
 
-#ifndef __has_attribute
-# /* Don't bother. */
-#elif RUBY3_COMPILER_IS(GCC) && ! __has_attribute(pure)
-# /* FreeBSD's   <sys/cdefs.h>   defines   its    own   *broken*   version   of
-#  * __has_attribute.  Cygwin copied that content to be a victim of the broken-
-#  * ness.  We don't take them into account. */
-#else
-# define RUBY3_HAVE___HAS_ATTRIBUTE 1
+#if defined(__has_attribute)
+# if __has_attribute(pure) || RUBY3_COMPILER_IS(GCC)
+#  /* FreeBSD's   <sys/cdefs.h>   defines   its   own   *broken*   version   of
+#   * __has_attribute.   Cygwin copied  that  content  to be  a  victim of  the
+#   * broken-ness.  We don't take them into account. */
+#  define RUBY3_HAVE___HAS_ATTRIBUTE 1
+# endif
 #endif
 
 /** Wraps (or simulates) `__has_attribute`. */
diff --git a/include/ruby/3/has/builtin.h b/include/ruby/3/has/builtin.h
index cce6435..e3f01ed 100644
--- a/include/ruby/3/has/builtin.h
+++ b/include/ruby/3/has/builtin.h
@@ -24,18 +24,18 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/3/has/builtin.h#L24
 #include "ruby/3/compiler_since.h"
 #include "ruby/3/token_paste.h"
 
-#ifndef __has_builtin
-# /* Don't bother. */
-#elif RUBY3_COMPILER_IS(Intel)
-# /* :TODO:  Intel C  Compiler has  __has_builtin (since  19.1 maybe?),  and is
-#  * reportedly  broken.  We  have to  skip  them.  However  the situation  can
-#  * change.  They might improve someday.  We need to revisit here later. */
-#elif RUBY3_COMPILER_IS(GCC) && ! __has_builtin(__builtin_alloca)
-# /* FreeBSD's <sys/cdefs.h> defines its own *broken* version of __has_builtin.
-#  * Cygwin copied  that content to be  a victim of the  broken-ness.  We don't
-#  * take them into account. */
-#else
-# define RUBY3_HAVE___HAS_BUILTIN 1
+#if defined(__has_builtin)
+# if RUBY3_COMPILER_IS(Intel)
+#  /* :TODO: Intel  C Compiler  has __has_builtin (since  19.1 maybe?),  and is
+#   * reportedly  broken.  We  have to  skip them.   However the  situation can
+#   * change.  They might improve someday.  We need to revisit here later. */
+# elif RUBY3_COMPILER_IS(GCC) && ! __has_builtin(__builtin_alloca)
+#  /* FreeBSD's   <sys/cdefs.h>   defines   its   own   *broken*   version   of
+#   * __has_builtin.   Cygwin  copied  that  content  to be  a  victim  of  the
+#   * broken-ness.  We don't take them into account. */
+# else
+#  define RUBY3_HAVE___HAS_BUILTIN 1
+# endif
 #endif
 
 /** Wraps (or simulates) `__has_builtin`. */
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]