]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR objc/22274 (string[1-4].m, const-str-5.m fails with the gnu runtime)
authorZiemowit Laski <zlaski@apple.com>
Thu, 7 Jul 2005 06:25:49 +0000 (06:25 +0000)
committerZiemowit Laski <zlaski@gcc.gnu.org>
Thu, 7 Jul 2005 06:25:49 +0000 (06:25 +0000)
/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.

From-SVN: r101686

gcc/objc/ChangeLog
gcc/objc/objc-act.c
gcc/testsuite/ChangeLog
gcc/testsuite/obj-c++.dg/gnu-runtime-1.mm [new file with mode: 0644]
gcc/testsuite/obj-c++.dg/gnu-runtime-2.mm [new file with mode: 0644]
gcc/testsuite/objc.dg/gnu-runtime-2.m [new file with mode: 0644]

index c9edce226088a1ced961d33b9299c97349f91590..6d7b9a4d9f15b5c2e1729bf635b48749a7ee3543 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2005-07-03  Kazu Hirata  <kazu@codesourcery.com>
 
        * Make-lang.in (cc1plus-checksum.c): Use
index a3d32d8ffa6f1e5205fa1109e64fc203e7860079..48cf70758632357371d2decde7e6812b5af10f2e 100644 (file)
@@ -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 7c793be17c0145feb37a72329dbd121054dee413..d8efcde2a6393c8577ad67e4c806a37ac1f4050e 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2005-07-06  Jeff Law  <law@redhat.com>
 
        * gcc.dg/tree-ssa/vrp17.c: New test.
diff --git a/gcc/testsuite/obj-c++.dg/gnu-runtime-1.mm b/gcc/testsuite/obj-c++.dg/gnu-runtime-1.mm
new file mode 100644 (file)
index 0000000..dab9215
--- /dev/null
@@ -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;
+}
+
diff --git a/gcc/testsuite/obj-c++.dg/gnu-runtime-2.mm b/gcc/testsuite/obj-c++.dg/gnu-runtime-2.mm
new file mode 100644 (file)
index 0000000..09204e3
--- /dev/null
@@ -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;
+}
diff --git a/gcc/testsuite/objc.dg/gnu-runtime-2.m b/gcc/testsuite/objc.dg/gnu-runtime-2.m
new file mode 100644 (file)
index 0000000..09204e3
--- /dev/null
@@ -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;
+}