diff options
| author | shebs <shebs@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-09-06 00:26:34 +0000 |
|---|---|---|
| committer | shebs <shebs@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-09-06 00:26:34 +0000 |
| commit | 6ae41c941ce4170104f80f2ae2c7f6ca8340f43b (patch) | |
| tree | f5f3d8aa668421ed73489dd49d533e1aed497a2a | |
| parent | 67dfd781d9cb33274cef83ea87796df006fd43e1 (diff) | |
| download | ppe42-gcc-6ae41c941ce4170104f80f2ae2c7f6ca8340f43b.tar.gz ppe42-gcc-6ae41c941ce4170104f80f2ae2c7f6ca8340f43b.zip | |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@45428 138bc75d-0d04-0410-961f-82ee72b054a4
| -rw-r--r-- | gcc/ChangeLog | 6 | ||||
| -rw-r--r-- | gcc/objc/objc-act.c | 7 | ||||
| -rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
| -rw-r--r-- | gcc/testsuite/objc.dg/method-2.m | 31 |
4 files changed, 45 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f05504f2edc..6605eb313d0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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. diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 3ff70456b72..358d0ea3b73 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -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); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 927522a2ce9..0b5516cb79b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 00000000000..b4cd4da6376 --- /dev/null +++ b/gcc/testsuite/objc.dg/method-2.m @@ -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 + |

