summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-30 21:27:27 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-30 21:27:27 +0000
commitc5fe7eb6f688c90208ff95da5bf4e86e54f62edf (patch)
tree4f033540473fd40695c09facafe1ae444fa69caa /class.c
parentb5583577d46e8aa1725840186e0f609cacec1bda (diff)
class.c: suppress wrong warning
* class.c (HAVE_METACLASS_P): should check FL_SINGLTON flag before get instance variable to get rid of wrong warning about __attached__. [ruby-core:53839] [Bug #8188] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r--class.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/class.c b/class.c
index c6af2c8..0f54a80 100644
--- a/class.c
+++ b/class.c
@@ -307,6 +307,14 @@ rb_singleton_class_attached(VALUE klass, VALUE obj)
*/
#define META_CLASS_OF_CLASS_CLASS_P(k) (METACLASS_OF(k) == (k))
+/*!
+ * whether k has a metaclass
+ * @retval 1 if \a k has a metaclass
+ * @retval 0 otherwise
+ */
+#define HAVE_METACLASS_P(k) \
+ (FL_TEST(METACLASS_OF(k), FL_SINGLETON) && \
+ rb_ivar_get(METACLASS_OF(k), id_attached) == (k))
/*!
* ensures \a klass belongs to its own eigenclass.
@@ -316,7 +324,7 @@ rb_singleton_class_attached(VALUE klass, VALUE obj)
* @note this macro creates a new eigenclass if necessary.
*/
#define ENSURE_EIGENCLASS(klass) \
- (rb_ivar_get(METACLASS_OF(klass), id_attached) == (klass) ? METACLASS_OF(klass) : make_metaclass(klass))
+ (HAVE_METACLASS_P(klass) ? METACLASS_OF(klass) : make_metaclass(klass))
/*!