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

ruby-changes:35241

From: nobu <ko1@a...>
Date: Sat, 30 Aug 2014 22:29:56 +0900 (JST)
Subject: [ruby-changes:35241] nobu:r47323 (trunk): internal.h: WARN_UNUSED_RESULT

nobu	2014-08-30 22:29:45 +0900 (Sat, 30 Aug 2014)

  New Revision: 47323

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

  Log:
    internal.h: WARN_UNUSED_RESULT
    
    * internal.h (WARN_UNUSED_RESULT): warn unused result by gcc 3.4
      or later.
    
    * symbol.c: declare some functions with WARN_UNUSED_RESULT.

  Modified files:
    trunk/internal.h
    trunk/symbol.c
Index: symbol.c
===================================================================
--- symbol.c	(revision 47322)
+++ symbol.c	(revision 47323)
@@ -103,8 +103,13 @@ Init_sym(void) https://github.com/ruby/ruby/blob/trunk/symbol.c#L103
     Init_id();
 }
 
-static ID attrsetname_to_attr(VALUE name);
-static VALUE lookup_id_str(ID id);
+WARN_UNUSED_RESULT(static VALUE dsymbol_alloc(const VALUE klass, const VALUE str, rb_encoding *const enc));
+WARN_UNUSED_RESULT(static VALUE dsymbol_check(const VALUE sym));
+WARN_UNUSED_RESULT(static ID dsymbol_pindown(VALUE sym));
+WARN_UNUSED_RESULT(static ID lookup_str_id(VALUE str));
+WARN_UNUSED_RESULT(static VALUE lookup_str_sym(const VALUE str));
+WARN_UNUSED_RESULT(static VALUE lookup_id_str(ID id));
+WARN_UNUSED_RESULT(static ID attrsetname_to_attr(VALUE name));
 
 ID
 rb_id_attrset(ID id)
Index: internal.h
===================================================================
--- internal.h	(revision 47322)
+++ internal.h	(revision 47323)
@@ -40,6 +40,14 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/internal.h#L40
 #define UNINITIALIZED_VAR(x) x
 #endif
 
+#if __has_attribute(warn_unused_result)
+#define WARN_UNUSED_RESULT(x) x __attribute__((warn_unused_result))
+#elif defined(__GNUC__) && (__GNUC__ * 1000 + __GNUC_MINOR__) >= 3004
+#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

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

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