This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Fix string snafu with -fgnu-runtime


Yes, I broke this. :-(  In addition to ICEing the compiler, one of
my previous patches was just plain wrong in that it wanted to emit
the built-in string name (__builtin_ObjCString) instead of the
user-visible one (NXConstantString by default).

I've added some test cases that will exercise this even on Darwin. :-(
Will commit after a sanity bootstrap.

--Zem


[gcc/objc/ChangeLog] 2005-07-07 Ziemowit Laski <zlaski@apple.com>

       PR objc/22274
       * objc-act.c (objc_build_string_object): For GNU-style constants,
       use the @interface type rather than the built-in type.

[gcc/testsuite/ChangeLog]
2005-07-07  Ziemowit Laski  <zlaski@apple.com>

       PR objc/22274
       * obj-c++.dg/gnu-runtime-[1-2].mm: New.
       * objc.dg/gnu-runtime-2.m: New.

Index: gcc/objc/objc-act.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/objc/objc-act.c,v
retrieving revision 1.284
diff -u -3 -p -r1.284 objc-act.c
--- gcc/objc/objc-act.c 2 Jul 2005 13:19:55 -0000       1.284
+++ gcc/objc/objc-act.c 7 Jul 2005 01:28:19 -0000
@@ -1915,7 +1915,7 @@ objc_build_string_object (tree string)

if (!flag_next_runtime)
constructor
- = objc_add_static_instance (constructor, internal_const_str_type);
+ = objc_add_static_instance (constructor, constant_string_type);
else
{
var = build_decl (CONST_DECL, NULL, TREE_TYPE (constructor));
Index: gcc/testsuite/obj-c++.dg/gnu-runtime-1.mm
===================================================================
RCS file: gcc/testsuite/obj-c++.dg/gnu-runtime-1.mm
diff -N gcc/testsuite/obj-c++.dg/gnu-runtime-1.mm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gcc/testsuite/obj-c++.dg/gnu-runtime-1.mm 7 Jul 2005 01:28:28 -0000
@@ -0,0 +1,19 @@
+/* Test that compiling for the GNU runtime works (regardless of
+ the system runtime used). */
+/* Author: Ziemowit Laski <zlaski@apple.com> */
+/* { dg-do compile } */
+/* { dg-options "-fgnu-runtime" } */
+
+#include <objc/Object.h>
+
+@interface FooBar: Object
+- (void)boo;
+@end
+
+int main ()
+{
+ id fooBarInst = [[FooBar alloc] init];
+ [fooBarInst boo];
+ return 0;
+}
+
Index: gcc/testsuite/obj-c++.dg/gnu-runtime-2.mm
===================================================================
RCS file: gcc/testsuite/obj-c++.dg/gnu-runtime-2.mm
diff -N gcc/testsuite/obj-c++.dg/gnu-runtime-2.mm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gcc/testsuite/obj-c++.dg/gnu-runtime-2.mm 7 Jul 2005 01:28:28 -0000
@@ -0,0 +1,30 @@
+/* Sanity check for GNU-runtime version of constant strings,
+ regardless of runtime used on target system. */
+
+/* { dg-do run } */
+/* { dg-options "-fgnu-runtime" } */
+
+#include <objc/Object.h>
+#include <string.h>
+#include <stdlib.h>
+
+@interface NXConstantString: Object
+{
+ char *c_string;
+ unsigned int len;
+}
+-(const char *) cString;
+-(unsigned int) length;
+@end
+
+@implementation NXConstantString
+-(const char *) cString { return c_string; }
+-(unsigned int) length { return len; }
+@end
+
+int main(int argc, void **args)
+{
+ if (strcmp ([@"this is a string" cString], "this is a string"))
+ abort ();
+ return 0;
+}
Index: gcc/testsuite/objc.dg/gnu-runtime-2.m
===================================================================
RCS file: gcc/testsuite/objc.dg/gnu-runtime-2.m
diff -N gcc/testsuite/objc.dg/gnu-runtime-2.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gcc/testsuite/objc.dg/gnu-runtime-2.m 7 Jul 2005 01:28:28 -0000
@@ -0,0 +1,30 @@
+/* Sanity check for GNU-runtime version of constant strings,
+ regardless of runtime used on target system. */
+
+/* { dg-do run } */
+/* { dg-options "-fgnu-runtime" } */
+
+#include <objc/Object.h>
+#include <string.h>
+#include <stdlib.h>
+
+@interface NXConstantString: Object
+{
+ char *c_string;
+ unsigned int len;
+}
+-(const char *) cString;
+-(unsigned int) length;
+@end
+
+@implementation NXConstantString
+-(const char *) cString { return c_string; }
+-(unsigned int) length { return len; }
+@end
+
+int main(int argc, void **args)
+{
+ if (strcmp ([@"this is a string" cString], "this is a string"))
+ abort ();
+ return 0;
+}


--------------------------------------------------------------
Ziemowit Laski                 1 Infinite Loop, MS 301-2K
Mac OS X Compiler Group        Cupertino, CA USA  95014-2083
Apple Computer, Inc.           +1.408.974.6229  Fax .5477


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]