objc-act.c (finish_class): Do not synthesize bogus 'extern objc_object *_Foo;' declar...
authorZiemowit Laski <zlaski@apple.com>
Tue, 26 Oct 2004 18:39:01 +0000 (18:39 +0000)
committerZiemowit Laski <zlaski@gcc.gnu.org>
Tue, 26 Oct 2004 18:39:01 +0000 (18:39 +0000)
[gcc/objc/ChangeLog]
2004-10-26  Ziemowit Laski  <zlaski@apple.com>

        * objc-act.c (finish_class): Do not synthesize bogus
        'extern objc_object *_Foo;' declarations for @interface Foo.

[gcc/testsuite/ChangeLog]
2004-10-26  Ziemowit Laski  <zlaski@apple.com>

        * objc.dg/super-class-3.m: New test.

From-SVN: r89601

gcc/objc/ChangeLog
gcc/objc/objc-act.c
gcc/testsuite/ChangeLog
gcc/testsuite/objc.dg/super-class-3.m [new file with mode: 0644]

index f781a1cefd55cd7d22d587053c2697a0b4b36577..7bb40f7cac9882f5e3d58b4a8552e1b4492b2e87 100644 (file)
@@ -1,3 +1,8 @@
+2004-10-26  Ziemowit Laski  <zlaski@apple.com>
+
+       * objc-act.c (finish_class): Do not synthesize bogus
+       'extern objc_object *_Foo;' declarations for @interface Foo.
+
 2004-10-25  Ziemowit Laski  <zlaski@apple.com>
            David Ayers  <d.ayers@inode.at>
 
index 21b279d5397b79bda13c1a5989e116e011495307..7b21ede8cdf8e7708e97387a84b692e5c4a9ff9c 100644 (file)
@@ -6896,23 +6896,6 @@ finish_class (tree class)
                             IDENTIFIER_POINTER (CLASS_SUPER_NAME (objc_implementation_context)));
        }
     }
-
-  else if (TREE_CODE (class) == CLASS_INTERFACE_TYPE)
-    {
-      tree decl;
-      const char *class_name = IDENTIFIER_POINTER (CLASS_NAME (class));
-      char *string = (char *) alloca (strlen (class_name) + 3);
-
-      /* extern struct objc_object *_<my_name>; */
-
-      sprintf (string, "_%s", class_name);
-
-      decl = build_decl (VAR_DECL, get_identifier (string),
-                        build_pointer_type (objc_object_reference));
-      DECL_EXTERNAL (decl) = 1;
-      lang_hooks.decls.pushdecl (decl);
-      finish_decl (decl, NULL_TREE, NULL_TREE);
-    }
 }
 
 static tree
index e8a8ec6bc07c3de744c1a6efeda5886b889d0a9d..4496f97ce8733ae9501eea5709c4199e6ae4bb28 100644 (file)
@@ -1,3 +1,7 @@
+2004-10-26  Ziemowit Laski  <zlaski@apple.com>
+
+       * objc.dg/super-class-3.m: New test.
+
 2004-10-26  Nathan Sidwell  <nathan@codesourcery.com>
 
        * gcc.dg/cpp/direct2.c: Adjust expected errors, robustify parser
diff --git a/gcc/testsuite/objc.dg/super-class-3.m b/gcc/testsuite/objc.dg/super-class-3.m
new file mode 100644 (file)
index 0000000..85396c2
--- /dev/null
@@ -0,0 +1,43 @@
+/* Ensure that the compiler does not emit spurious extern declarations named '_Foo', where 'Foo'
+   is an ObjC class name.  */
+/* Contributed by Ziemowit Laski <zlaski@apple.com>.  */
+/* { dg-do run } */
+
+#include <objc/Object.h>
+#include <stdlib.h>
+#define CHECK_IF(expr) if(!(expr)) abort()
+
+@interface _Child: Object
++ (int) flashCache;
+@end
+
+@interface Child: _Child
++ (int) flushCache1;
+@end
+
+@interface Child (Categ)
++ (int) flushCache2;
+@end
+
+int _Object = 23;  /* Should not conflict with @interface Object.  */
+
+@implementation _Child
++ (int) flashCache { return 12 + _Object; }
+@end
+
+@implementation Child
++ (int) flushCache1 { return 7 + [super flashCache]; }
+@end
+
+@implementation Child (Categ)
++ (int) flushCache2 { return 9 + [super flashCache]; }
+@end
+
+int main(void) {
+  CHECK_IF([_Child flashCache] == 35);
+  CHECK_IF([Child flushCache1] == 42);
+  CHECK_IF([Child flushCache2] == 44);
+
+  return 0; 
+}
+