From: Ziemowit Laski Date: Mon, 26 Aug 2002 21:17:20 +0000 (+0000) Subject: objc-act.c (get_super_receiver): If inside a class method of a category... X-Git-Tag: releases/gcc-3.3.0~3159 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d632dee9cb93ec0e45e070207046742019464d55;p=thirdparty%2Fgcc.git objc-act.c (get_super_receiver): If inside a class method of a category... [gcc] 2002-08-26 Ziemowit Laski * objc/objc-act.c (get_super_receiver): If inside a class method of a category, cast the receiver to 'id' before accessing the 'isa' field so that is not needed. For NeXT runtime. [gcc/testsuite] 2002-08-26 Ziemowit Laski * objc.dg/super-class-2.m: New test. From-SVN: r56587 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4192aad6bc7e..4783fea3a840 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2002-08-26 Ziemowit Laski + + * objc/objc-act.c (get_super_receiver): If inside a class method + of a category, cast the receiver to 'id' before accessing the 'isa' + field so that is not needed. For NeXT runtime. + 2002-08-26 Ulrich Weigand * config/s390/s390-protos.h (s390_function_prologue, diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index e1c630d6be60..081936913699 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -7042,9 +7042,13 @@ get_super_receiver () { super_class = get_class_reference (super_name); if (TREE_CODE (objc_method_context) == CLASS_METHOD_DECL) + /* Cast the super class to 'id', since the user may not have + included , leaving 'struct objc_class' + an incomplete type. */ super_class - = build_component_ref (build_indirect_ref (super_class, "->"), - get_identifier ("isa")); + = build_component_ref (build_indirect_ref + (build_c_cast (id_type, super_class), "->"), + get_identifier ("isa")); } else { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f509299f6e5d..496fc950a9dc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2002-08-26 Ziemowit Laski + + * objc.dg/super-class-2.m: New test. + 2002-08-24 Matt Austern * g++.dg/ext/lvaddr.C: New test. diff --git a/gcc/testsuite/objc.dg/super-class-2.m b/gcc/testsuite/objc.dg/super-class-2.m new file mode 100644 index 000000000000..15d018e7db80 --- /dev/null +++ b/gcc/testsuite/objc.dg/super-class-2.m @@ -0,0 +1,45 @@ +/* Test calling super from within a category class method. */ +/* Author: Ziemowit Laski */ +/* { dg-do compile } */ +/* { dg-options "-fnext-runtime" } */ + +typedef struct objc_object { struct objc_class *isa; } *id; + +@interface NSObject ++ (int) test_func0; +@end +@interface NSMenuItem: NSObject ++ (int) test_func0; +@end + +@implementation NSObject ++ (int) test_func0 +{} +@end + +@implementation NSMenuItem ++ (int) test_func0 +{ + return [super test_func0]; +} +@end + +@interface NSObject (Test) ++ (int) test_func; +@end + +@implementation NSObject (Test) ++ (int) test_func +{} +@end + +@interface NSMenuItem (Test) ++ (int) test_func; +@end + +@implementation NSMenuItem (Test) ++ (int) test_func +{ + return [super test_func]; /* { dg-bogus "dereferencing pointer to incomplete type" } */ +} +@end