mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* internal.h (WARN_UNUSED_RESULT): moved to configure.in, to
actually check its availability rather to check GCC's version. * configure.in (WARN_UNUSED_RESULT): moved to here. * configure.in (RUBY_FUNC_ATTRIBUTE): change function declaration to return int rather than void, because it makes no sense for a warn_unused_result attributed function to return void. Funny thing however is that it also makes no sense for noreturn attributed function to return int. So there is a fundamental conflict between them. While I tested this, I confirmed both GCC 6 and Clang 3.8 prefers int over void to correctly detect necessary attributes under this setup. Maybe subject to change in future. * internal.h (UNINITIALIZED_VAR): renamed to MAYBE_UNUSED, then moved to configure.in for the same reason we move WARN_UNUSED_RESULT. * configure.in (MAYBE_UNUSED): moved to here. * internal.h (__has_attribute): deleted, because it has no use now. * string.c (rb_str_enumerate_lines): refactor macro rename. * string.c (rb_str_enumerate_bytes): ditto. * string.c (rb_str_enumerate_chars): ditto. * string.c (rb_str_enumerate_codepoints): ditto. * thread.c (do_select): ditto. * vm_backtrace.c (rb_debug_inspector_open): ditto. * vsnprintf.c (BSD_vfprintf): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									921c477646
								
							
						
					
					
						commit
						2fc5210f31
					
				
					 7 changed files with 54 additions and 32 deletions
				
			
		
							
								
								
									
										40
									
								
								ChangeLog
									
										
									
									
									
								
							
							
						
						
									
										40
									
								
								ChangeLog
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,3 +1,43 @@
 | 
			
		|||
Fri Sep 16 14:54:34 2016  URABE Shyouhei  <shyouhei@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* internal.h (WARN_UNUSED_RESULT): moved to configure.in, to
 | 
			
		||||
	  actually check its availability rather to check GCC's version.
 | 
			
		||||
 | 
			
		||||
	* configure.in (WARN_UNUSED_RESULT): moved to here.
 | 
			
		||||
 | 
			
		||||
	* configure.in (RUBY_FUNC_ATTRIBUTE): change function declaration
 | 
			
		||||
	  to return int rather than void, because it makes no sense for a
 | 
			
		||||
	  warn_unused_result attributed function to return void.
 | 
			
		||||
 | 
			
		||||
	  Funny thing however is that it also makes no sense for noreturn
 | 
			
		||||
	  attributed function to return int.  So there is a fundamental
 | 
			
		||||
	  conflict between them.  While I tested this, I confirmed both
 | 
			
		||||
	  GCC 6 and Clang 3.8 prefers int over void to correctly detect
 | 
			
		||||
	  necessary attributes under this setup.  Maybe subject to change
 | 
			
		||||
	  in future.
 | 
			
		||||
 | 
			
		||||
	* internal.h (UNINITIALIZED_VAR): renamed to MAYBE_UNUSED, then
 | 
			
		||||
	  moved to configure.in for the same reason we move
 | 
			
		||||
	  WARN_UNUSED_RESULT.
 | 
			
		||||
 | 
			
		||||
	* configure.in (MAYBE_UNUSED): moved to here.
 | 
			
		||||
 | 
			
		||||
	* internal.h (__has_attribute): deleted, because it has no use now.
 | 
			
		||||
 | 
			
		||||
	* string.c (rb_str_enumerate_lines): refactor macro rename.
 | 
			
		||||
 | 
			
		||||
	* string.c (rb_str_enumerate_bytes): ditto.
 | 
			
		||||
 | 
			
		||||
	* string.c (rb_str_enumerate_chars): ditto.
 | 
			
		||||
 | 
			
		||||
	* string.c (rb_str_enumerate_codepoints): ditto.
 | 
			
		||||
 | 
			
		||||
	* thread.c (do_select): ditto.
 | 
			
		||||
 | 
			
		||||
	* vm_backtrace.c (rb_debug_inspector_open): ditto.
 | 
			
		||||
 | 
			
		||||
	* vsnprintf.c (BSD_vfprintf): ditto.
 | 
			
		||||
 | 
			
		||||
Fri Sep 16 14:35:55 2016  URABE Shyouhei  <shyouhei@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* ChangeLog (add-log-time-format): Not exactly sure when but
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1809,7 +1809,7 @@ AS_VAR_POPDEF([rbcv])dnl
 | 
			
		|||
dnl RUBY_FUNC_ATTRIBUTE(attrib, macroname, cachevar, condition)
 | 
			
		||||
AC_DEFUN([RUBY_FUNC_ATTRIBUTE], [dnl
 | 
			
		||||
    RUBY_DECL_ATTRIBUTE([$1], [$2], [$3], [$4],
 | 
			
		||||
	[function], [@%:@define x void conftest_attribute_check(void)]
 | 
			
		||||
	[function], [@%:@define x int conftest_attribute_check(void)]
 | 
			
		||||
    )
 | 
			
		||||
])
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1829,6 +1829,8 @@ RUBY_FUNC_ATTRIBUTE(__deprecated__("by "@%:@n), DEPRECATED_BY(n,x), rb_cv_func_d
 | 
			
		|||
RUBY_TYPE_ATTRIBUTE(__deprecated__ mesg, DEPRECATED_TYPE(mesg,x), rb_cv_type_deprecated)
 | 
			
		||||
RUBY_FUNC_ATTRIBUTE(__noinline__, NOINLINE)
 | 
			
		||||
RUBY_FUNC_ATTRIBUTE(__always_inline__, ALWAYS_INLINE)
 | 
			
		||||
RUBY_FUNC_ATTRIBUTE(__warn_unused_result__, WARN_UNUSED_RESULT)
 | 
			
		||||
RUBY_FUNC_ATTRIBUTE(__unused__, MAYBE_UNUSED)
 | 
			
		||||
RUBY_FUNC_ATTRIBUTE(__error__ mesg, ERRORFUNC(mesg,x), rb_cv_func___error__)
 | 
			
		||||
RUBY_FUNC_ATTRIBUTE(__warning__ mesg, WARNINGFUNC(mesg,x), rb_cv_func___warning__)
 | 
			
		||||
RUBY_FUNC_ATTRIBUTE(__weak__, WEAK, rb_cv_func_weak)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										20
									
								
								internal.h
									
										
									
									
									
								
							
							
						
						
									
										20
									
								
								internal.h
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -26,26 +26,6 @@ extern "C" {
 | 
			
		|||
#define LIKELY(x) RB_LIKELY(x)
 | 
			
		||||
#define UNLIKELY(x) RB_UNLIKELY(x)
 | 
			
		||||
 | 
			
		||||
#ifndef __has_attribute
 | 
			
		||||
# define __has_attribute(x) 0
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if __has_attribute(__unused__)
 | 
			
		||||
#define UNINITIALIZED_VAR(x) x __attribute__((__unused__))
 | 
			
		||||
#elif defined(__GNUC__) && __GNUC__ >= 3
 | 
			
		||||
#define UNINITIALIZED_VAR(x) x = x
 | 
			
		||||
#else
 | 
			
		||||
#define UNINITIALIZED_VAR(x) x
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if __has_attribute(__warn_unused_result__)
 | 
			
		||||
#define WARN_UNUSED_RESULT(x) x __attribute__((__warn_unused_result__))
 | 
			
		||||
#elif GCC_VERSION_SINCE(3,4,0)
 | 
			
		||||
#define WARN_UNUSED_RESULT(x) x __attribute__((__warn_unused_result__))
 | 
			
		||||
#else
 | 
			
		||||
#define WARN_UNUSED_RESULT(x) x
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef HAVE_VALGRIND_MEMCHECK_H
 | 
			
		||||
# include <valgrind/memcheck.h>
 | 
			
		||||
# ifndef VALGRIND_MAKE_MEM_DEFINED
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										8
									
								
								string.c
									
										
									
									
									
								
							
							
						
						
									
										8
									
								
								string.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -7348,7 +7348,7 @@ rb_str_enumerate_lines(int argc, VALUE *argv, VALUE str, int wantarray)
 | 
			
		|||
    long pos, len, rslen;
 | 
			
		||||
    int paragraph_mode = 0;
 | 
			
		||||
 | 
			
		||||
    VALUE UNINITIALIZED_VAR(ary);
 | 
			
		||||
    VALUE MAYBE_UNUSED(ary);
 | 
			
		||||
 | 
			
		||||
    if (argc == 0)
 | 
			
		||||
	rs = rb_rs;
 | 
			
		||||
| 
						 | 
				
			
			@ -7522,7 +7522,7 @@ static VALUE
 | 
			
		|||
rb_str_enumerate_bytes(VALUE str, int wantarray)
 | 
			
		||||
{
 | 
			
		||||
    long i;
 | 
			
		||||
    VALUE UNINITIALIZED_VAR(ary);
 | 
			
		||||
    VALUE MAYBE_UNUSED(ary);
 | 
			
		||||
 | 
			
		||||
    if (rb_block_given_p()) {
 | 
			
		||||
	if (wantarray) {
 | 
			
		||||
| 
						 | 
				
			
			@ -7606,7 +7606,7 @@ rb_str_enumerate_chars(VALUE str, int wantarray)
 | 
			
		|||
    long i, len, n;
 | 
			
		||||
    const char *ptr;
 | 
			
		||||
    rb_encoding *enc;
 | 
			
		||||
    VALUE UNINITIALIZED_VAR(ary);
 | 
			
		||||
    VALUE MAYBE_UNUSED(ary);
 | 
			
		||||
 | 
			
		||||
    str = rb_str_new_frozen(str);
 | 
			
		||||
    ptr = RSTRING_PTR(str);
 | 
			
		||||
| 
						 | 
				
			
			@ -7705,7 +7705,7 @@ rb_str_enumerate_codepoints(VALUE str, int wantarray)
 | 
			
		|||
    unsigned int c;
 | 
			
		||||
    const char *ptr, *end;
 | 
			
		||||
    rb_encoding *enc;
 | 
			
		||||
    VALUE UNINITIALIZED_VAR(ary);
 | 
			
		||||
    VALUE MAYBE_UNUSED(ary);
 | 
			
		||||
 | 
			
		||||
    if (single_byte_optimizable(str))
 | 
			
		||||
	return rb_str_enumerate_bytes(str, wantarray);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										8
									
								
								thread.c
									
										
									
									
									
								
							
							
						
						
									
										8
									
								
								thread.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -3660,11 +3660,11 @@ static int
 | 
			
		|||
do_select(int n, rb_fdset_t *readfds, rb_fdset_t *writefds,
 | 
			
		||||
	  rb_fdset_t *exceptfds, struct timeval *timeout)
 | 
			
		||||
{
 | 
			
		||||
    int UNINITIALIZED_VAR(result);
 | 
			
		||||
    int MAYBE_UNUSED(result);
 | 
			
		||||
    int lerrno;
 | 
			
		||||
    rb_fdset_t UNINITIALIZED_VAR(orig_read);
 | 
			
		||||
    rb_fdset_t UNINITIALIZED_VAR(orig_write);
 | 
			
		||||
    rb_fdset_t UNINITIALIZED_VAR(orig_except);
 | 
			
		||||
    rb_fdset_t MAYBE_UNUSED(orig_read);
 | 
			
		||||
    rb_fdset_t MAYBE_UNUSED(orig_write);
 | 
			
		||||
    rb_fdset_t MAYBE_UNUSED(orig_except);
 | 
			
		||||
    double limit = 0;
 | 
			
		||||
    struct timeval wait_rest;
 | 
			
		||||
    rb_thread_t *th = GET_THREAD();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1173,7 +1173,7 @@ rb_debug_inspector_open(rb_debug_inspector_func_t func, void *data)
 | 
			
		|||
    rb_debug_inspector_t dbg_context;
 | 
			
		||||
    rb_thread_t *th = GET_THREAD();
 | 
			
		||||
    int state;
 | 
			
		||||
    volatile VALUE UNINITIALIZED_VAR(result);
 | 
			
		||||
    volatile VALUE MAYBE_UNUSED(result);
 | 
			
		||||
 | 
			
		||||
    dbg_context.th = th;
 | 
			
		||||
    dbg_context.cfp = dbg_context.th->cfp;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -558,9 +558,9 @@ BSD_vfprintf(FILE *fp, const char *fmt0, va_list ap)
 | 
			
		|||
	int fprec = 0;		/* floating point precision */
 | 
			
		||||
	char expstr[7];		/* buffer for exponent string */
 | 
			
		||||
#endif
 | 
			
		||||
	u_long UNINITIALIZED_VAR(ulval); /* integer arguments %[diouxX] */
 | 
			
		||||
	u_long MAYBE_UNUSED(ulval); /* integer arguments %[diouxX] */
 | 
			
		||||
#ifdef _HAVE_SANE_QUAD_
 | 
			
		||||
	u_quad_t UNINITIALIZED_VAR(uqval); /* %q integers */
 | 
			
		||||
	u_quad_t MAYBE_UNUSED(uqval); /* %q integers */
 | 
			
		||||
#endif /* _HAVE_SANE_QUAD_ */
 | 
			
		||||
	int base;		/* base for [diouxX] conversion */
 | 
			
		||||
	int dprec;		/* a copy of prec if [diouxX], 0 otherwise */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue