aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/obj-c++.dg/const-str-8.mm
diff options
context:
space:
mode:
authorno-author <no-author@gcc.gnu.org>2005-07-22 07:31:32 +0000
committerno-author <no-author@gcc.gnu.org>2005-07-22 07:31:32 +0000
commitea85b3c5c3e92a70dabb440b249f7c97cdb3045f (patch)
tree2d00554ce3107c7986bcf8019547e9fa8d7708b7 /gcc/testsuite/obj-c++.dg/const-str-8.mm
parent06dbf9039672be06678a949dc384273e5a4ea8c1 (diff)
This commit was manufactured by cvs2svn to create branch 'cfo-branch'.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/cfo-branch@102274 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/obj-c++.dg/const-str-8.mm')
-rw-r--r--gcc/testsuite/obj-c++.dg/const-str-8.mm39
1 files changed, 39 insertions, 0 deletions
diff --git a/gcc/testsuite/obj-c++.dg/const-str-8.mm b/gcc/testsuite/obj-c++.dg/const-str-8.mm
new file mode 100644
index 00000000000..60abcbd52b1
--- /dev/null
+++ b/gcc/testsuite/obj-c++.dg/const-str-8.mm
@@ -0,0 +1,39 @@
+/* Test for assigning compile-time constant-string objects to static variables. */
+/* Contributed by Ziemowit Laski <zlaski@apple.com> */
+
+/* { dg-options "-fnext-runtime -fconstant-string-class=Foo -lobjc" } */
+/* { dg-do run { target *-*-darwin* } } */
+
+
+#include <stdlib.h>
+#include <objc/Object.h>
+
+@interface Foo: Object {
+ char *cString;
+ unsigned int len;
+}
+@end
+
+struct objc_class _FooClassReference;
+
+@implementation Foo : Object
+- (char *)customString {
+ return cString;
+}
+@end
+
+static const Foo *appKey = @"MyApp";
+static int CFPreferencesSynchronize (const Foo *ref) {
+ return ref == appKey;
+}
+
+static void PrefsSynchronize(void)
+{
+ if(!CFPreferencesSynchronize(appKey))
+ abort();
+}
+
+int main () {
+ PrefsSynchronize();
+ return 0;
+}