1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ngoto 2016-05-20 12:29:06 +00:00
parent 27c13f82b9
commit 2b97ab88e0
6 changed files with 75 additions and 68 deletions

View file

@ -1,3 +1,19 @@
Fri May 20 21:26:58 2016 Naohisa Goto <ngotogenome@gmail.com>
* 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@ruby-lang.org>
* ext/win32ole/win32ole.c (fole_missing): make substring or dup to

View file

@ -4,12 +4,11 @@
*/
#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

View file

@ -71,6 +71,14 @@ extern "C" {
#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

View file

@ -146,18 +146,16 @@ VALUE rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to);
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);

View file

@ -791,79 +791,67 @@ VALUE rb_str_scrub(VALUE, VALUE);
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

View file

@ -1325,12 +1325,11 @@ VALUE rb_fstring_new(const char *ptr, long len);
#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, long len, rb_encoding *enc);
#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);