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

ruby-changes:59519

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Fri, 27 Dec 2019 10:53:35 +0900 (JST)
Subject: [ruby-changes:59519] 6581db2187 (master): internal/warnings.h rework

https://git.ruby-lang.org/ruby.git/commit/?id=6581db2187

From 6581db2187a1d5b6316fd1c942dccc6b6a3b9ca8 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: Mon, 2 Dec 2019 17:02:24 +0900
Subject: internal/warnings.h rework

Not a big rewrite.  Just to make those macros readable.

diff --git a/internal/warnings.h b/internal/warnings.h
index 9575839..82b3ac5 100644
--- a/internal/warnings.h
+++ b/internal/warnings.h
@@ -9,42 +9,41 @@ https://github.com/ruby/ruby/blob/trunk/internal/warnings.h#L9
  *             modify this file, provided that  the conditions mentioned in the
  *             file COPYING are met.  Consult the file for details.
  */
+#include "internal/compilers.h" /* for MSC_VERSION_SINCE */
 
-#if defined(_MSC_VER)
+#if MSC_VERSION_SINCE(1200)
+# /* Not sure exactly when but it seems VC++ 6.0 is a version with it.*/
 # define COMPILER_WARNING_PUSH          __pragma(warning(push))
 # define COMPILER_WARNING_POP           __pragma(warning(pop))
-# define COMPILER_WARNING_ERROR(flag)   __pragma(warning(error: flag)))
-# define COMPILER_WARNING_IGNORED(flag) __pragma(warning(suppress: flag)))
+# define COMPILER_WARNING_ERROR(flag)   __pragma(warning(error: flag))
+# define COMPILER_WARNING_IGNORED(flag) __pragma(warning(disable: flag))
 
-#elif defined(__clang__) /* clang 2.6 already had this feature */
-# define COMPILER_WARNING_PUSH          _Pragma("clang diagnostic push")
-# define COMPILER_WARNING_POP           _Pragma("clang diagnostic pop")
-# define COMPILER_WARNING_SPECIFIER(kind, msg) \
-    clang diagnostic kind # msg
-# define COMPILER_WARNING_ERROR(flag) \
-    COMPILER_WARNING_PRAGMA(COMPILER_WARNING_SPECIFIER(error, flag))
-# define COMPILER_WARNING_IGNORED(flag) \
-    COMPILER_WARNING_PRAGMA(COMPILER_WARNING_SPECIFIER(ignored, flag))
+#elif defined(__clang__)
+# /* Not sure exactly when but it seems LLVM 2.6.0 is a version with it. */
+# define COMPILER_WARNING_PRAGMA0(x)    _Pragma(# x)
+# define COMPILER_WARNING_PRAGMA1(x)    COMPILER_WARNING_PRAGMA0(clang diagnostic x)
+# define COMPILER_WARNING_PRAGMA2(x, y) COMPILER_WARNING_PRAGMA1(x # y)
+# define COMPILER_WARNING_PUSH          COMPILER_WARNING_PRAGMA1(push)
+# define COMPILER_WARNING_POP           COMPILER_WARNING_PRAGMA1(pop)
+# define COMPILER_WARNING_ERROR(flag)   COMPILER_WARNING_PRAGMA2(error, flag)
+# define COMPILER_WARNING_IGNORED(flag) COMPILER_WARNING_PRAGMA2(ignored, flag)
 
 #elif GCC_VERSION_SINCE(4, 6, 0)
-/* https://gcc.gnu.org/onlinedocs/gcc-4.6.4/gcc/Diagnostic-Pragmas.html */
-# define COMPILER_WARNING_PUSH          _Pragma("GCC diagnostic push")
-# define COMPILER_WARNING_POP           _Pragma("GCC diagnostic pop")
-# define COMPILER_WARNING_SPECIFIER(kind, msg) \
-    GCC diagnostic kind # msg
-# define COMPILER_WARNING_ERROR(flag) \
-    COMPILER_WARNING_PRAGMA(COMPILER_WARNING_SPECIFIER(error, flag))
-# define COMPILER_WARNING_IGNORED(flag) \
-    COMPILER_WARNING_PRAGMA(COMPILER_WARNING_SPECIFIER(ignored, flag))
+# /* https://gcc.gnu.org/onlinedocs/gcc-4.6.0/gcc/Diagnostic-Pragmas.html */
+# define COMPILER_WARNING_PRAGMA0(x)    _Pragma(# x)
+# define COMPILER_WARNING_PRAGMA1(x)    COMPILER_WARNING_PRAGMA0(GCC diagnostic x)
+# define COMPILER_WARNING_PRAGMA2(x, y) COMPILER_WARNING_PRAGMA1(x # y)
+# define COMPILER_WARNING_PUSH          COMPILER_WARNING_PRAGMA1(push)
+# define COMPILER_WARNING_POP           COMPILER_WARNING_PRAGMA1(pop)
+# define COMPILER_WARNING_ERROR(flag)   COMPILER_WARNING_PRAGMA2(error, flag)
+# define COMPILER_WARNING_IGNORED(flag) COMPILER_WARNING_PRAGMA2(ignored, flag)
 
-#else /* other compilers to follow? */
-# define COMPILER_WARNING_PUSH          /* nop */
-# define COMPILER_WARNING_POP           /* nop */
-# define COMPILER_WARNING_ERROR(flag)   /* nop */
-# define COMPILER_WARNING_IGNORED(flag) /* nop */
-#endif
-
-#define COMPILER_WARNING_PRAGMA(str) COMPILER_WARNING_PRAGMA_(str)
-#define COMPILER_WARNING_PRAGMA_(str) _Pragma(#str)
+#else
+# /* :FIXME: improve here, for instace icc seems to have something? */
+# define COMPILER_WARNING_PUSH          /* void */
+# define COMPILER_WARNING_POP           /* void */
+# define COMPILER_WARNING_ERROR(flag)   /* void */
+# define COMPILER_WARNING_IGNORED(flag) /* void */
 
+#endif /* _MSC_VER */
 #endif /* INTERNAL_WARNINGS_H */
-- 
cgit v0.10.2


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

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