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

ruby-changes:43008

From: ngoto <ko1@a...>
Date: Fri, 20 May 2016 21:29:10 +0900 (JST)
Subject: [ruby-changes:43008] ngoto:r55082 (trunk): Use RB_GNUC_EXTENSION_BLOCK instead of __extension__

ngoto	2016-05-20 21:29:06 +0900 (Fri, 20 May 2016)

  New Revision: 55082

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55082

  Log:
    Use RB_GNUC_EXTENSION_BLOCK instead of __extension__
    
    * include/ruby/defines.h (RB_GNUC_EXTENSION, RB_GNUC_EXTENSION_BLOCK):
      macros for skipping __extension__ on non-GCC compilers.
    * eval_error.c (warn_print): use RB_GNUC_EXTENSION_BLOCK instead of
      __extension__ because __extension__ is a GNU extension.
      Fix compile error on Solaris 10 with Oracle Solaris Studio 12.x.
      [Bug #12397] [ruby-dev:49629].
    * internal.h (rb_fstring_cstr, rb_fstring_enc_cstr): ditto
    * include/ruby/encoding.h (rb_enc_str_new, rb_enc_str_new_cstr): ditto
    * include/ruby/intern.h (rb_str_new, rb_str_new_cstr,
      rb_usascii_str_new, rb_utf8_str_new, rb_tainted_str_new_cstr,
      rb_usascii_str_new_cstr, rb_utf8_str_new_cstr,
      rb_external_str_new_cstr, rb_locale_str_new_cstr,
      rb_str_buf_new_cstr, rb_str_cat_cstr, rb_exc_new_cstr): ditto

  Modified files:
    trunk/ChangeLog
    trunk/eval_error.c
    trunk/include/ruby/defines.h
    trunk/include/ruby/encoding.h
    trunk/include/ruby/intern.h
    trunk/internal.h
Index: include/ruby/intern.h
===================================================================
--- include/ruby/intern.h	(revision 55081)
+++ include/ruby/intern.h	(revision 55082)
@@ -791,79 +791,67 @@ VALUE rb_str_scrub(VALUE, VALUE); https://github.com/ruby/ruby/blob/trunk/include/ruby/intern.h#L791
 VALUE rb_sym_all_symbols(void);
 
 #ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
-#define rb_str_new(str, len) __extension__ (	\
-{						\
+#define rb_str_new(str, len) RB_GNUC_EXTENSION_BLOCK(	\
     (__builtin_constant_p(str) && __builtin_constant_p(len)) ? \
 	rb_str_new_static((str), (len)) : \
-	rb_str_new((str), (len));	  \
-})
-#define rb_str_new_cstr(str) __extension__ (	\
-{						\
+	rb_str_new((str), (len))	  \
+)
+#define rb_str_new_cstr(str) RB_GNUC_EXTENSION_BLOCK(	\
     (__builtin_constant_p(str)) ?		\
 	rb_str_new_static((str), (long)strlen(str)) : \
-	rb_str_new_cstr(str);			\
-})
-#define rb_usascii_str_new(str, len) __extension__ ( \
-{						\
+	rb_str_new_cstr(str)			\
+)
+#define rb_usascii_str_new(str, len) RB_GNUC_EXTENSION_BLOCK( \
     (__builtin_constant_p(str) && __builtin_constant_p(len)) ? \
 	rb_usascii_str_new_static((str), (len)) : \
-	rb_usascii_str_new((str), (len));	  \
-})
-#define rb_utf8_str_new(str, len) __extension__ ( \
-{						\
+	rb_usascii_str_new((str), (len))	  \
+)
+#define rb_utf8_str_new(str, len) RB_GNUC_EXTENSION_BLOCK( \
     (__builtin_constant_p(str) && __builtin_constant_p(len)) ? \
 	rb_utf8_str_new_static((str), (len)) : \
-	rb_utf8_str_new((str), (len));	  \
-})
-#define rb_tainted_str_new_cstr(str) __extension__ ( \
-{					       \
+	rb_utf8_str_new((str), (len))	  \
+)
+#define rb_tainted_str_new_cstr(str) RB_GNUC_EXTENSION_BLOCK( \
     (__builtin_constant_p(str)) ?	       \
 	rb_tainted_str_new((str), (long)strlen(str)) : \
-	rb_tainted_str_new_cstr(str);	       \
-})
-#define rb_usascii_str_new_cstr(str) __extension__ ( \
-{					       \
+	rb_tainted_str_new_cstr(str)	       \
+)
+#define rb_usascii_str_new_cstr(str) RB_GNUC_EXTENSION_BLOCK( \
     (__builtin_constant_p(str)) ?	       \
 	rb_usascii_str_new_static((str), (long)strlen(str)) : \
-	rb_usascii_str_new_cstr(str);	       \
-})
-#define rb_utf8_str_new_cstr(str) __extension__ ( \
-{						\
+	rb_usascii_str_new_cstr(str)	       \
+)
+#define rb_utf8_str_new_cstr(str) RB_GNUC_EXTENSION_BLOCK( \
     (__builtin_constant_p(str)) ?		\
 	rb_utf8_str_new_static((str), (long)strlen(str)) : \
-	rb_utf8_str_new_cstr(str);		\
-})
-#define rb_external_str_new_cstr(str) __extension__ ( \
-{						\
+	rb_utf8_str_new_cstr(str)		\
+)
+#define rb_external_str_new_cstr(str) RB_GNUC_EXTENSION_BLOCK( \
     (__builtin_constant_p(str)) ?		\
 	rb_external_str_new((str), (long)strlen(str)) : \
-	rb_external_str_new_cstr(str);		\
-})
-#define rb_locale_str_new_cstr(str) __extension__ ( \
-{					       \
+	rb_external_str_new_cstr(str)		\
+)
+#define rb_locale_str_new_cstr(str) RB_GNUC_EXTENSION_BLOCK( \
     (__builtin_constant_p(str)) ?	       \
 	rb_locale_str_new((str), (long)strlen(str)) :  \
-	rb_locale_str_new_cstr(str);	       \
-})
-#define rb_str_buf_new_cstr(str) __extension__ ( \
-{						\
+	rb_locale_str_new_cstr(str)	       \
+)
+#define rb_str_buf_new_cstr(str) RB_GNUC_EXTENSION_BLOCK( \
     (__builtin_constant_p(str)) ?		\
 	rb_str_buf_cat(rb_str_buf_new((long)strlen(str)), \
 		       (str), (long)strlen(str)) : \
-	rb_str_buf_new_cstr(str);		\
-})
-#define rb_str_cat_cstr(str, ptr) __extension__ ( \
-{						\
+	rb_str_buf_new_cstr(str)		\
+)
+#define rb_str_cat_cstr(str, ptr) RB_GNUC_EXTENSION_BLOCK( \
     (__builtin_constant_p(ptr)) ?	        \
 	rb_str_cat((str), (ptr), (long)strlen(ptr)) : \
-	rb_str_cat_cstr((str), (ptr));		\
-})
-#define rb_exc_new_cstr(klass, ptr) __extension__ ( \
-{						\
+	rb_str_cat_cstr((str), (ptr))		\
+)
+#define rb_exc_new_cstr(klass, ptr) RB_GNUC_EXTENSION_BLOCK( \
     (__builtin_constant_p(ptr)) ?	        \
 	rb_exc_new((klass), (ptr), (long)strlen(ptr)) : \
-	rb_exc_new_cstr((klass), (ptr));		\
-})
+	rb_exc_new_cstr((klass), (ptr))		\
+)
 #endif
 #define rb_str_new2 rb_str_new_cstr
 #define rb_str_new3 rb_str_new_shared
Index: include/ruby/defines.h
===================================================================
--- include/ruby/defines.h	(revision 55081)
+++ include/ruby/defines.h	(revision 55082)
@@ -71,6 +71,14 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/include/ruby/defines.h#L71
 #define PRINTF_ARGS(decl, string_index, first_to_check) decl
 #endif
 
+#ifdef __GNUC__
+#define RB_GNUC_EXTENSION __extension__
+#define RB_GNUC_EXTENSION_BLOCK(x) __extension__ ({ x; })
+#else
+#define RB_GNUC_EXTENSION
+#define RB_GNUC_EXTENSION_BLOCK(x) (x)
+#endif
+
 /* AC_INCLUDES_DEFAULT */
 #include <stdio.h>
 #ifdef HAVE_SYS_TYPES_H
Index: include/ruby/encoding.h
===================================================================
--- include/ruby/encoding.h	(revision 55081)
+++ include/ruby/encoding.h	(revision 55082)
@@ -146,18 +146,16 @@ VALUE rb_str_conv_enc(VALUE str, rb_enco https://github.com/ruby/ruby/blob/trunk/include/ruby/encoding.h#L146
 VALUE rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts);
 
 #ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
-#define rb_enc_str_new(str, len, enc) __extension__ ( \
-{					       \
+#define rb_enc_str_new(str, len, enc) RB_GNUC_EXTENSION_BLOCK( \
     (__builtin_constant_p(str) && __builtin_constant_p(len)) ? \
 	rb_enc_str_new_static((str), (len), (enc)) : \
-	rb_enc_str_new((str), (len), (enc)); \
-})
-#define rb_enc_str_new_cstr(str, enc) __extension__ (	\
-{					       \
+	rb_enc_str_new((str), (len), (enc)) \
+)
+#define rb_enc_str_new_cstr(str, enc) RB_GNUC_EXTENSION_BLOCK(	\
     (__builtin_constant_p(str)) ?	       \
 	rb_enc_str_new_static((str), (long)strlen(str), (enc)) : \
-	rb_enc_str_new_cstr((str), (enc)); \
-})
+	rb_enc_str_new_cstr((str), (enc)) \
+)
 #endif
 
 PRINTF_ARGS(NORETURN(void rb_enc_raise(rb_encoding *, VALUE, const char*, ...)), 3, 4);
Index: eval_error.c
===================================================================
--- eval_error.c	(revision 55081)
+++ eval_error.c	(revision 55082)
@@ -4,12 +4,11 @@ https://github.com/ruby/ruby/blob/trunk/eval_error.c#L4
  */
 
 #ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
-#define warn_print(x) __extension__ (	\
-{						\
+#define warn_print(x) RB_GNUC_EXTENSION_BLOCK(	\
     (__builtin_constant_p(x)) ? 		\
 	rb_write_error2((x), (long)strlen(x)) : \
-	rb_write_error(x);			\
-})
+	rb_write_error(x)			\
+)
 #else
 #define warn_print(x) rb_write_error(x)
 #endif
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 55081)
+++ ChangeLog	(revision 55082)
@@ -1,3 +1,19 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri May 20 21:26:58 2016  Naohisa Goto  <ngotogenome@g...>
+
+	* include/ruby/defines.h (RB_GNUC_EXTENSION, RB_GNUC_EXTENSION_BLOCK):
+	  macros for skipping __extension__ on non-GCC compilers.
+	* eval_error.c (warn_print): use RB_GNUC_EXTENSION_BLOCK instead of
+	  __extension__ because __extension__ is a GNU extension.
+	  Fix compile error on Solaris 10 with Oracle Solaris Studio 12.x.
+	  [Bug #12397] [ruby-dev:49629].
+	* internal.h (rb_fstring_cstr, rb_fstring_enc_cstr): ditto
+	* include/ruby/encoding.h (rb_enc_str_new, rb_enc_str_new_cstr): ditto
+	* include/ruby/intern.h (rb_str_new, rb_str_new_cstr,
+	  rb_usascii_str_new, rb_utf8_str_new, rb_tainted_str_new_cstr,
+	  rb_usascii_str_new_cstr, rb_utf8_str_new_cstr,
+	  rb_external_str_new_cstr, rb_locale_str_new_cstr,
+	  rb_str_buf_new_cstr, rb_str_cat_cstr, rb_exc_new_cstr): ditto
+
 Fri May 20 21:17:13 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* ext/win32ole/win32ole.c (fole_missing): make substring or dup to
Index: internal.h
===================================================================
--- internal.h	(revision 55081)
+++ internal.h	(revision 55082)
@@ -1325,12 +1325,11 @@ VALUE rb_fstring_new(const char *ptr, lo https://github.com/ruby/ruby/blob/trunk/internal.h#L1325
 #define rb_fstring_literal(str) rb_fstring_lit(str)
 VALUE rb_fstring_cstr(const char *str);
 #ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
-# define rb_fstring_cstr(str) __extension__ (	\
-{						\
+# define rb_fstring_cstr(str) RB_GNUC_EXTENSION_BLOCK(	\
     (__builtin_constant_p(str)) ?		\
 	rb_fstring_new((str), (long)strlen(str)) : \
-	rb_fstring_cstr(str); \
-})
+	rb_fstring_cstr(str) \
+)
 #endif
 #ifdef RUBY_ENCODING_H
 VALUE rb_fstring_enc_new(const char *ptr, long len, rb_encoding *enc);
@@ -1338,12 +1337,11 @@ VALUE rb_fstring_enc_new(const char *ptr https://github.com/ruby/ruby/blob/trunk/internal.h#L1337
 #define rb_fstring_enc_literal(str, enc) rb_fstring_enc_lit(str, enc)
 VALUE rb_fstring_enc_cstr(const char *ptr, rb_encoding *enc);
 # ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
-#  define rb_fstring_enc_cstr(str, enc) __extension__ ( \
-{						\
+#  define rb_fstring_enc_cstr(str, enc) RB_GNUC_EXTENSION_BLOCK( \
     (__builtin_constant_p(str)) ?		\
 	rb_fstring_enc_new((str), (long)strlen(str), (enc)) : \
-	rb_fstring_enc_cstr(str, enc); \
-})
+	rb_fstring_enc_cstr(str, enc) \
+)
 # endif
 #endif
 int rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p);

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

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