diff options
author | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-04-09 16:07:29 +0900 |
---|---|---|
committer | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-04-10 16:17:30 +0900 |
commit | 3e92785fd6ec4bf584128fcd255b01ff4448ea2b (patch) | |
tree | bf20d6d16d9b0e4b89b1064b2eaa88eef93154b3 | |
parent | d69c5326856b8e5df35688cd12c15a7cbdf89f1c (diff) | |
download | ruby-3e92785fd6ec4bf584128fcd255b01ff4448ea2b.tar.gz |
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.
-rw-r--r-- | include/ruby/3/assume.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/include/ruby/3/assume.h b/include/ruby/3/assume.h index cbd02637a2..3d60aee81a 100644 --- a/include/ruby/3/assume.h +++ b/include/ruby/3/assume.h @@ -28,6 +28,7 @@ #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 @@ #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) |