summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2021-04-09 17:56:43 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2021-04-13 14:30:21 +0900
commitf411fcd14587cfbf1efb86944134b993c04b050e (patch)
tree2a8eafc72186f56061625165bf450b86f98ca52c
parent6878d51731c596fa4dc375b997c1c883d585db02 (diff)
get rid of #pragma GCC diagnostic ignored "-Wundef"
Use of TOKEN_PASTE was a bad idea at the first place. Just use ## everywhere. Nobody practically lacks token pasting.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4371
-rw-r--r--include/ruby/internal/attr/constexpr.h2
-rw-r--r--include/ruby/internal/attr/restrict.h2
-rw-r--r--include/ruby/internal/core/rdata.h6
-rw-r--r--include/ruby/internal/has/attribute.h6
-rw-r--r--include/ruby/internal/has/builtin.h4
-rw-r--r--include/ruby/internal/has/cpp_attribute.h6
-rw-r--r--include/ruby/internal/has/declspec_attribute.h2
-rw-r--r--include/ruby/internal/token_paste.h75
8 files changed, 16 insertions, 87 deletions
diff --git a/include/ruby/internal/attr/constexpr.h b/include/ruby/internal/attr/constexpr.h
index dabb724..3e5feaf 100644
--- a/include/ruby/internal/attr/constexpr.h
+++ b/include/ruby/internal/attr/constexpr.h
@@ -67,7 +67,7 @@
# define RBIMPL_ATTR_CONSTEXPR(_) constexpr
#elif RBIMPL_HAS_ATTR_CONSTEXPR_CXX11
-# define RBIMPL_ATTR_CONSTEXPR(_) RBIMPL_TOKEN_PASTE(RBIMPL_ATTR_CONSTEXPR_, _)
+# define RBIMPL_ATTR_CONSTEXPR(_) RBIMPL_ATTR_CONSTEXPR_ ## _
# define RBIMPL_ATTR_CONSTEXPR_CXX11 constexpr
# define RBIMPL_ATTR_CONSTEXPR_CXX14 /* void */
diff --git a/include/ruby/internal/attr/restrict.h b/include/ruby/internal/attr/restrict.h
index 3f4b7db..3c69312 100644
--- a/include/ruby/internal/attr/restrict.h
+++ b/include/ruby/internal/attr/restrict.h
@@ -30,7 +30,7 @@
/** Wraps (or simulates) `__declspec(restrict)` */
#if RBIMPL_COMPILER_SINCE(MSVC, 14, 0, 0)
-# define RBIMPL_ATTR_RESTRICT() __declspec(RBIMPL_TOKEN_PASTE(re, strict))
+# define RBIMPL_ATTR_RESTRICT() __declspec(re ## strict)
#elif RBIMPL_HAS_ATTRIBUTE(malloc)
# define RBIMPL_ATTR_RESTRICT() __attribute__((__malloc__))
diff --git a/include/ruby/internal/core/rdata.h b/include/ruby/internal/core/rdata.h
index ca44a93..146c5f3 100644
--- a/include/ruby/internal/core/rdata.h
+++ b/include/ruby/internal/core/rdata.h
@@ -54,7 +54,8 @@
#define RDATA(obj) RBIMPL_CAST((struct RData *)(obj))
#define DATA_PTR(obj) RDATA(obj)->data
-#define RUBY_MACRO_SELECT RBIMPL_TOKEN_PASTE
+#define RBIMPL_MACRO_SELECT(x, y) x ## y
+#define RUBY_MACRO_SELECT(x, y) RBIMPL_MACRO_SELECT(x, y)
#define RUBY_DEFAULT_FREE RBIMPL_DATA_FUNC(-1)
#define RUBY_NEVER_FREE RBIMPL_DATA_FUNC(0)
#define RUBY_UNTYPED_DATA_FUNC(f) f RBIMPL_ATTRSET_UNTYPED_DATA_FUNC()
@@ -174,11 +175,14 @@ rb_cData(void)
#define rb_data_object_wrap_0 rb_data_object_wrap
#define rb_data_object_wrap_1 rb_data_object_wrap_warning
+#define rb_data_object_wrap_ rb_data_object_wrap_ /* Used here vvvv */
#define rb_data_object_wrap RUBY_MACRO_SELECT(rb_data_object_wrap_, RUBY_UNTYPED_DATA_WARNING)
#define rb_data_object_get_0 rb_data_object_get
#define rb_data_object_get_1 rb_data_object_get_warning
+#define rb_data_object_get_ rb_data_object_get_ /* Used here vvvv */
#define rb_data_object_get RUBY_MACRO_SELECT(rb_data_object_get_, RUBY_UNTYPED_DATA_WARNING)
#define rb_data_object_make_0 rb_data_object_make
#define rb_data_object_make_1 rb_data_object_make_warning
+#define rb_data_object_make_ rb_data_object_make_ /* Used here vvvv */
#define rb_data_object_make RUBY_MACRO_SELECT(rb_data_object_make_, RUBY_UNTYPED_DATA_WARNING)
#endif /* RBIMPL_RDATA_H */
diff --git a/include/ruby/internal/has/attribute.h b/include/ruby/internal/has/attribute.h
index 512f061..f5d9bbd 100644
--- a/include/ruby/internal/has/attribute.h
+++ b/include/ruby/internal/has/attribute.h
@@ -40,7 +40,7 @@
#elif RBIMPL_COMPILER_IS(GCC)
# /* GCC <= 4 lack __has_attribute predefined macro, while have attributes
# * themselves. We can simulate the macro like the following: */
-# define RBIMPL_HAS_ATTRIBUTE(_) RBIMPL_TOKEN_PASTE(RBIMPL_HAS_ATTRIBUTE_, _)
+# define RBIMPL_HAS_ATTRIBUTE(_) (RBIMPL_HAS_ATTRIBUTE_ ## _)
# define RBIMPL_HAS_ATTRIBUTE_aligned RBIMPL_COMPILER_SINCE(GCC, 0, 0, 0)
# define RBIMPL_HAS_ATTRIBUTE_alloc_size RBIMPL_COMPILER_SINCE(GCC, 4, 3, 0)
# define RBIMPL_HAS_ATTRIBUTE_artificial RBIMPL_COMPILER_SINCE(GCC, 4, 3, 0)
@@ -78,7 +78,7 @@
# /* Oracle Solaris Studio 12.4 (cc version 5.11) introduced __has_attribute.
# * Before that, following attributes were available. */
# /* See https://docs.oracle.com/cd/F24633_01/index.html */
-# define RBIMPL_HAS_ATTRIBUTE(_) RBIMPL_TOKEN_PASTE(RBIMPL_HAS_ATTRIBUTE_, _)
+# define RBIMPL_HAS_ATTRIBUTE(_) (RBIMPL_HAS_ATTRIBUTE_ ## _)
# define RBIMPL_HAS_ATTRIBUTE_alias RBIMPL_COMPILER_SINCE(SunPro, 5, 9, 0)
# define RBIMPL_HAS_ATTRIBUTE_aligned RBIMPL_COMPILER_SINCE(SunPro, 5, 9, 0)
# define RBIMPL_HAS_ATTRIBUTE_always_inline RBIMPL_COMPILER_SINCE(SunPro, 5, 10, 0)
@@ -101,7 +101,7 @@
#else
# /* Take config.h definition when available. */
-# define RBIMPL_HAS_ATTRIBUTE(_) (RBIMPL_TOKEN_PASTE(RBIMPL_HAS_ATTRIBUTE_, _)+0)
+# define RBIMPL_HAS_ATTRIBUTE(_) ((RBIMPL_HAS_ATTRIBUTE_ ## _)+0)
# ifdef ALWAYS_INLINE
# define RBIMPL_HAS_ATTRIBUTE_always_inline 1
# endif
diff --git a/include/ruby/internal/has/builtin.h b/include/ruby/internal/has/builtin.h
index 18cfc69..ece354a 100644
--- a/include/ruby/internal/has/builtin.h
+++ b/include/ruby/internal/has/builtin.h
@@ -47,7 +47,7 @@
# * __has_builtin only since GCC 10. This section can be made more
# * granular. */
# /* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66970 */
-# define RBIMPL_HAS_BUILTIN(_) RBIMPL_TOKEN_PASTE(RBIMPL_HAS_BUILTIN_, _)
+# define RBIMPL_HAS_BUILTIN(_) (RBIMPL_HAS_BUILTIN_ ## _)
# define RBIMPL_HAS_BUILTIN___builtin_add_overflow RBIMPL_COMPILER_SINCE(GCC, 5, 1, 0)
# define RBIMPL_HAS_BUILTIN___builtin_alloca RBIMPL_COMPILER_SINCE(GCC, 0, 0, 0)
# define RBIMPL_HAS_BUILTIN___builtin_alloca_with_align RBIMPL_COMPILER_SINCE(GCC, 6, 1, 0)
@@ -78,7 +78,7 @@
#else
# /* Take config.h definition when available */
-# define RBIMPL_HAS_BUILTIN(_) (RBIMPL_TOKEN_PASTE(RBIMPL_HAS_BUILTIN_, _)+0)
+# define RBIMPL_HAS_BUILTIN(_) ((RBIMPL_HAS_BUILTIN_ ## _)+0)
# define RBIMPL_HAS_BUILTIN___builtin_add_overflow HAVE_BUILTIN___BUILTIN_ADD_OVERFLOW
# define RBIMPL_HAS_BUILTIN___builtin_alloca_with_align HAVE_BUILTIN___BUILTIN_ALLOCA_WITH_ALIGN
# define RBIMPL_HAS_BUILTIN___builtin_assume_aligned HAVE_BUILTIN___BUILTIN_ASSUME_ALIGNED
diff --git a/include/ruby/internal/has/cpp_attribute.h b/include/ruby/internal/has/cpp_attribute.h
index 255f611..a30646c 100644
--- a/include/ruby/internal/has/cpp_attribute.h
+++ b/include/ruby/internal/has/cpp_attribute.h
@@ -42,7 +42,7 @@
# * explicitly by a compiler flag). They also lack __has_cpp_attribute until
# * 2019. However, they do have attributes since 2015 or so. */
# /* https://docs.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance */
-# define RBIMPL_HAS_CPP_ATTRIBUTE0(_) RBIMPL_TOKEN_PASTE(RBIMPL_HAS_CPP_ATTRIBUTE_, _)
+# define RBIMPL_HAS_CPP_ATTRIBUTE0(_) (RBIMPL_HAS_CPP_ATTRIBUTE_ ## _)
# define RBIMPL_HAS_CPP_ATTRIBUTE_noreturn 200809 * RBIMPL_COMPILER_SINCE(MSVC, 19, 00, 0)
# define RBIMPL_HAS_CPP_ATTRIBUTE_carries_dependency 200809 * RBIMPL_COMPILER_SINCE(MSVC, 19, 00, 0)
# define RBIMPL_HAS_CPP_ATTRIBUTE_deprecated 201309 * RBIMPL_COMPILER_SINCE(MSVC, 19, 10, 0)
@@ -54,14 +54,14 @@
# /* Clang 3.6.0 introduced __has_cpp_attribute. Prior to that following
# * attributes were already there. */
# /* https://clang.llvm.org/cxx_status.html */
-# define RBIMPL_HAS_CPP_ATTRIBUTE0(_) RBIMPL_TOKEN_PASTE(RBIMPL_HAS_CPP_ATTRIBUTE_, _)
+# define RBIMPL_HAS_CPP_ATTRIBUTE0(_) (RBIMPL_HAS_CPP_ATTRIBUTE_ ## _)
# define RBIMPL_HAS_CPP_ATTRIBUTE_noreturn 200809 * RBIMPL_COMPILER_SINCE(Clang, 3, 3, 0)
# define RBIMPL_HAS_CPP_ATTRIBUTE_deprecated 201309 * RBIMPL_COMPILER_SINCE(Clang, 3, 4, 0)
#elif RBIMPL_COMPILER_BEFORE(GCC, 5, 0, 0)
# /* GCC 5+ have __has_cpp_attribute, while 4.x had following attributes. */
# /* https://gcc.gnu.org/projects/cxx-status.html */
-# define RBIMPL_HAS_CPP_ATTRIBUTE0(_) RBIMPL_TOKEN_PASTE(RBIMPL_HAS_CPP_ATTRIBUTE_, _)
+# define RBIMPL_HAS_CPP_ATTRIBUTE0(_) (RBIMPL_HAS_CPP_ATTRIBUTE_ ## _)
# define RBIMPL_HAS_CPP_ATTRIBUTE_noreturn 200809 * RBIMPL_COMPILER_SINCE(GCC, 4, 8, 0)
# define RBIMPL_HAS_CPP_ATTRIBUTE_deprecated 201309 * RBIMPL_COMPILER_SINCE(GCC, 4, 9, 0)
diff --git a/include/ruby/internal/has/declspec_attribute.h b/include/ruby/internal/has/declspec_attribute.h
index 0261033..9d54a68 100644
--- a/include/ruby/internal/has/declspec_attribute.h
+++ b/include/ruby/internal/has/declspec_attribute.h
@@ -27,7 +27,7 @@
#if defined(__has_declspec_attribute)
# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE(_) __has_declspec_attribute(_)
#else
-# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE(_) RBIMPL_TOKEN_PASTE(RBIMPL_HAS_DECLSPEC_ATTRIBUTE_, _)
+# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE(_) (RBIMPL_HAS_DECLSPEC_ATTRIBUTE_ ## _)
# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE_align RBIMPL_COMPILER_SINCE(MSVC, 8, 0, 0)
# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE_deprecated RBIMPL_COMPILER_SINCE(MSVC,13, 0, 0)
# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE_dllexport RBIMPL_COMPILER_SINCE(MSVC, 8, 0, 0)
diff --git a/include/ruby/internal/token_paste.h b/include/ruby/internal/token_paste.h
deleted file mode 100644
index c42f7a6..0000000
--- a/include/ruby/internal/token_paste.h
+++ /dev/null
@@ -1,75 +0,0 @@
-#ifndef RBIMPL_TOKEN_PASTE_H /*-*-C++-*-vi:se ft=cpp:*/
-#define RBIMPL_TOKEN_PASTE_H
-/**
- * @file
- * @author Ruby developers <ruby-core@ruby-lang.org>
- * @copyright This file is a part of the programming language Ruby.
- * Permission is hereby granted, to either redistribute and/or
- * modify this file, provided that the conditions mentioned in the
- * file COPYING are met. Consult the file for details.
- * @warning Symbols prefixed with either `RBIMPL` or `rbimpl` are
- * implementation details. Don't take them as canon. They could
- * rapidly appear then vanish. The name (path) of this header file
- * is also an implementation detail. Do not expect it to persist
- * at the place it is now. Developers are free to move it anywhere
- * anytime at will.
- * @note To ruby-core: remember that this header can be possibly
- * recursively included from extension libraries written in C++.
- * Do not expect for instance `__VA_ARGS__` is always available.
- * We assume C99 for ruby itself but we don't assume languages of
- * extension libraries. They could be written in C++98.
- * @brief Defines #RBIMPL_TOKEN_PASTE.
- */
-#include "ruby/internal/config.h"
-#include "ruby/internal/compiler_since.h"
-#include "ruby/internal/has/warning.h"
-#include "ruby/internal/warning_push.h"
-
-/* :TODO: add your compiler here. There are many compilers that can suppress
- * warnings via pragmas, but not all of them accept such things inside of `#if`
- * and variants' conditions. And such nitpicking behavours tend not be
- * documented. Please improve this file when you are really sure about your
- * compiler's behaviour. */
-
-#if RBIMPL_COMPILER_SINCE(GCC, 4, 2, 0)
-# /* GCC is one of such compiler who cannot write `_Pragma` inside of a `#if`.
-# * Cannot but globally kill everything. This is of course a very bad thing.
-# * If you know how to reroute this please tell us. */
-# /* https://gcc.godbolt.org/z/K2xr7X */
-# define RBIMPL_TOKEN_PASTE(x, y) TOKEN_PASTE(x, y)
-# pragma GCC diagnostic ignored "-Wundef"
-# /* > warning: "symbol" is not defined, evaluates to 0 [-Wundef] */
-
-#elif RBIMPL_COMPILER_IS(Intel)
-# /* Ditto for icc. */
-# /* https://gcc.godbolt.org/z/pTwDxE */
-# define RBIMPL_TOKEN_PASTE(x, y) TOKEN_PASTE(x, y)
-# pragma warning(disable: 193)
-# /* > warning #193: zero used for undefined preprocessing identifier */
-
-#elif RBIMPL_COMPILER_BEFORE(MSVC, 19, 14, 26428)
-# /* :FIXME: is 19.14 the exact version they supported this? */
-# define RBIMPL_TOKEN_PASTE(x, y) TOKEN_PASTE(x, y)
-# pragma warning(disable: 4668)
-# /* > warning C4668: 'symbol' is not defined as a preprocessor macro */
-
-#elif RBIMPL_COMPILER_IS(MSVC)
-# define RBIMPL_TOKEN_PASTE(x, y) \
- RBIMPL_WARNING_PUSH() \
- RBIMPL_WARNING_IGNORED(4668) \
- TOKEN_PASTE(x, y) \
- RBIMPL_WARNING_POP()
-
-#elif RBIMPL_HAS_WARNING("-Wundef")
-# define RBIMPL_TOKEN_PASTE(x, y) \
- RBIMPL_WARNING_PUSH() \
- RBIMPL_WARNING_IGNORED(-Wundef) \
- TOKEN_PASTE(x, y) \
- RBIMPL_WARNING_POP()
-
-#else
-# /* No way. */
-# define RBIMPL_TOKEN_PASTE(x, y) TOKEN_PASTE(x, y)
-#endif
-
-#endif /* RBIMPL_TOKEN_PASTE_H */