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

ruby-changes:60728

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Fri, 10 Apr 2020 16:17:54 +0900 (JST)
Subject: [ruby-changes:60728] 3e92785fd6 (master): RUBY3_ASSUME: suppress warnings on icc

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

From 3e92785fd6ec4bf584128fcd255b01ff4448ea2b 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, 9 Apr 2020 16:07:29 +0900
Subject: RUBY3_ASSUME: suppress warnings on icc

icc warns side effects for RUBY3_ASSUME like this:

> ./include/ruby/3/value_type.h(202): warning #2261: __assume expression with side effects discarded
>           RUBY3_ASSUME(RB_FLONUM_P(obj));
>                        ^

Which is a false positive (RB_FLONUM_P has no side effect).  It seems
there is no way for us to tell icc that a functin is safe inside of
__assume.   Just suppress the warning instead.

diff --git a/include/ruby/3/assume.h b/include/ruby/3/assume.h
index cbd0263..3d60aee 100644
--- a/include/ruby/3/assume.h
+++ b/include/ruby/3/assume.h
@@ -28,6 +28,7 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/3/assume.h#L28
 #include "ruby/3/config.h"
 #include "ruby/3/cast.h"
 #include "ruby/3/has/builtin.h"
+#include "ruby/3/warning_push.h"
 
 /** @cond INTERNAL_MACRO */
 #if RUBY3_COMPILER_SINCE(MSVC, 13, 10, 0)
@@ -58,7 +59,16 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/3/assume.h#L59
 #endif
 
 /** Wraps (or simulates) `__asume`. */
-#if defined(RUBY3_HAVE___ASSUME)
+#if RUBY3_COMPILER_SINCE(Intel, 13, 0, 0)
+# /* icc warnings are false positives.  Ignore them. */
+# /* "warning #2261: __assume expression with side effects discarded" */
+# define RUBY3_ASSUME(expr)     \
+    RUBY3_WARNING_PUSH()        \
+    RUBY3_WARNING_IGNORED(2261) \
+    __assume(expr)              \
+    RUBY3_WARNING_POP()
+
+#elif defined(RUBY3_HAVE___ASSUME)
 # define RUBY3_ASSUME __assume
 
 #elif RUBY3_HAS_BUILTIN(__builtin_assume)
-- 
cgit v0.10.2


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

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