+2001-09-05 Ziemowit Laski <zlaski@apple.com>
+
+ * objc/objc-act.c (build_message_expr): If a class method cannot
+ be found, do not issue a warning if a corresponding instance
+ method exists in the root class.
+
2001-09-05 Richard Henderson <rth@redhat.com>
* config/alpha/alpha.c (alpha_expand_mov): Initialize temp.
method_prototype = lookup_class_method_static (iface, sel_name);
}
- if (!method_prototype
- || TREE_CODE (method_prototype) != CLASS_METHOD_DECL)
+ if (!method_prototype)
{
warning ("cannot find class (factory) method.");
warning ("return type for `%s' defaults to id",
}
while (inter);
- /* Simulate wrap around. */
+ /* If no class (factory) method was found, check if an _instance_
+ method of the same name exists in the root class. This is what
+ the Objective-C runtime will do. */
return lookup_instance_method_static (root_inter, ident);
}
+2001-09-05 Ziemowit Laski <zlaski@apple.com>
+
+ * objc.dg/method-2.m: New.
+
2001-09-04 Nathan Sidwell <nathan@codesourcery.com>
PR c++/4203
--- /dev/null
+/* Test for lookup of class (factory) methods. */
+/* Author: Ziemowit Laski <zlaski@apple.com>. */
+/* { dg-do compile } */
+
+@interface MyBase
+- (void) rootInstanceMethod;
+@end
+
+@interface MyIntermediate: MyBase
+@end
+
+@interface MyDerived: MyIntermediate
+- (void) instanceMethod;
++ (void) classMethod;
+@end
+
+@implementation MyDerived
+- (void) instanceMethod {
+}
+
++ (void) classMethod { /* If a class method is not found, the root */
+ [self rootInstanceMethod]; /* class is searched for an instance method */
+ [MyIntermediate rootInstanceMethod]; /* with the same name. */
+
+ [self instanceMethod]; /* { dg-warning "cannot find class" } */
+ /* { dg-warning "defaults to id" "" { target *-*-* } 25 } */
+ [MyDerived instanceMethod]; /* { dg-warning "cannot find class" } */
+ /* { dg-warning "defaults to id" "" { target *-*-* } 27 } */
+}
+@end
+