]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
objc-act.c (build_message_expr): If a class method cannot be found...
authorZiemowit Laski <zlaski@apple.com>
Thu, 6 Sep 2001 00:26:34 +0000 (00:26 +0000)
committerStan Shebs <shebs@gcc.gnu.org>
Thu, 6 Sep 2001 00:26:34 +0000 (00:26 +0000)
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  Ziemowit Laski  <zlaski@apple.com>

        * objc.dg/method-2.m: New.

From-SVN: r45428

gcc/ChangeLog
gcc/objc/objc-act.c
gcc/testsuite/ChangeLog
gcc/testsuite/objc.dg/method-2.m [new file with mode: 0644]

index f05504f2edce421eedcc2b9241381c3d0c0deb3c..6605eb313d01e6dc3995e33af66e19edede83926 100644 (file)
@@ -1,3 +1,9 @@
+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.
index 3ff70456b72dd692d84a4d19bbcb6777720ac81c..358d0ea3b73159d38ceed3f54ce518f1d82a89b6 100644 (file)
@@ -5177,8 +5177,7 @@ build_message_expr (mess)
            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",
@@ -5687,7 +5686,9 @@ lookup_class_method_static (interface, ident)
     }
   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);
 }
 
index 927522a2ce968c51075a7cac38d160b8bed8cfd8..0b5516cb79b8bc22207f1fc8efdb0c38ae3c5b11 100644 (file)
@@ -1,3 +1,7 @@
+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
diff --git a/gcc/testsuite/objc.dg/method-2.m b/gcc/testsuite/objc.dg/method-2.m
new file mode 100644 (file)
index 0000000..b4cd4da
--- /dev/null
@@ -0,0 +1,31 @@
+/* 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
+