Fixed a couple of objctective-c bugs.
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 2 Mar 2006 17:45:30 +0000 (17:45 +0000)
committerFariborz Jahanian <fjahanian@gcc.gnu.org>
Thu, 2 Mar 2006 17:45:30 +0000 (17:45 +0000)
Oked by Mike Stump.

From-SVN: r111642

gcc/objc/ChangeLog
gcc/objc/objc-act.c
gcc/testsuite/ChangeLog
gcc/testsuite/obj-c++.dg/bad-receiver-type.mm [new file with mode: 0644]
gcc/testsuite/objc.dg/bad-receiver-type.m [new file with mode: 0644]
gcc/testsuite/objc.dg/objc-nofilename-1.m [new file with mode: 0644]

index 321fe2ead0b6d021710010310d526a81638ba0d5..67ccd3be55e3ffc6f30dce9b9bcc73954240f25a 100644 (file)
@@ -1,3 +1,9 @@
+2006-03-02 Fariborz Jahanian <fjahanian@apple.com>
+
+       * objc-act.c (init_module_descriptor): Remove file name from
+       module descriptor.
+       (gen_type_name_0): Fix ICE when issuing warning.
+
 2006-02-20 Rafael Ávila de Espíndola <rafael.espindola@gmail.com>
        * Make-lang.in (OBJC): Remove
        (OBJECTIVE-C): Remove
index 463ceed5db6304a9db924986ff48dfda62e1afcc..a90c0614b5e8cec53484c350a6f0b1d6a8caaee5 100644 (file)
@@ -2254,9 +2254,10 @@ init_module_descriptor (tree type)
                  size_in_bytes (objc_module_template));
   initlist = tree_cons (NULL_TREE, expr, initlist);
 
-  /* name = { ..., "foo.m", ... } */
+  /* Don't provide any file name for security reasons. */
+  /* name = { ..., "", ... } */
 
-  expr = add_objc_string (get_identifier (input_filename), class_names);
+  expr = add_objc_string (get_identifier (""), class_names);
   initlist = tree_cons (NULL_TREE, expr, initlist);
 
   /* symtab = { ..., _OBJC_SYMBOLS, ... } */
@@ -8883,7 +8884,9 @@ gen_type_name_0 (tree type)
   if (TREE_CODE (type) == TYPE_DECL && DECL_NAME (type))
     type = DECL_NAME (type);
 
-  strcat (errbuf, IDENTIFIER_POINTER (type));
+  strcat (errbuf, TREE_CODE (type) == IDENTIFIER_NODE
+                 ? IDENTIFIER_POINTER (type)
+                 : "");
 
   /* For 'id' and 'Class', adopted protocols are stored in the pointee.  */
   if (objc_is_id (orig))
index f53333bf61f875e4df57baa686cd565791b43991..e94df364083e6246f75f267ec358b47f51efeab6 100644 (file)
@@ -1,3 +1,9 @@
+2006-03-02  Fariborz Jahanian <fjahanian@apple.com>
+
+       * objc.dg/objc-nofilename-1.m: New test.
+       * objc.dg/bad-receiver-type.m: New test.
+       * obj-c++.dg/bad-receiver-type.mm: New test.
+
 2006-03-02  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * gcc.dg/single-precision-constant.c: Tweak for non-C99 runtimes.
diff --git a/gcc/testsuite/obj-c++.dg/bad-receiver-type.mm b/gcc/testsuite/obj-c++.dg/bad-receiver-type.mm
new file mode 100644 (file)
index 0000000..1d6699f
--- /dev/null
@@ -0,0 +1,15 @@
+// { dg-do compile } 
+// { dg-options "" }
+
+@interface A
+
+- (void)test; 
+
+@end
+
+extern int foo();
+
+void baz()
+{
+    [foo test];        /* { dg-warning "invalid receiver type" } */
+}
diff --git a/gcc/testsuite/objc.dg/bad-receiver-type.m b/gcc/testsuite/objc.dg/bad-receiver-type.m
new file mode 100644 (file)
index 0000000..58a5bb8
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+@interface A
+
+- (void)test; 
+
+@end
+
+extern int foo();
+
+void baz()
+{
+    [foo test];        /* { dg-warning "invalid receiver type" } */ 
+               /* { dg-warning "cannot convert to a pointer type" "" { target *-*-* } 13} */
+}
diff --git a/gcc/testsuite/objc.dg/objc-nofilename-1.m b/gcc/testsuite/objc.dg/objc-nofilename-1.m
new file mode 100644 (file)
index 0000000..0bd49ff
--- /dev/null
@@ -0,0 +1,21 @@
+/* Test to make sure that file name does not appear in the binary. */
+/* { dg-do compile } */
+#include <objc/objc.h>
+
+@interface Foo { Class isa; } @end
+@implementation Foo @end
+
+@interface Bar : Foo { Class Barisa; } @end
+
+@implementation Bar : Foo @end;
+
+@interface FINAL : Bar { Class FINALisa; } @end
+
+@implementation FINAL : Bar @end;
+
+int main(int argc, char **argv)
+{
+     return 0;
+}
+
+/* { dg-final { scan-assembler-not "objc-nofilename-1.m" } } */