OSDN Git Service

2005-06-28 Thomas Koenig <Thomas.Koenig@online.de>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / objc.dg / const-str-7.m
1 /* Test to make sure that the const objc strings are the same across
2    scopes.  */
3 /* Developed by Andrew Pinski <pinskia@physics.uc.edu> */
4
5
6 /* { dg-options "-fnext-runtime -fconstant-string-class=Foo -lobjc" } */
7 /* { dg-do run { target *-*-darwin* } } */
8
9
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <memory.h>
13 #include <objc/objc.h>
14 #include <objc/Object.h>
15
16
17 @interface Foo: Object {
18   char *cString;
19   unsigned int len;
20 }
21 - (char *)customString;
22 @end
23
24 struct objc_class _FooClassReference;
25
26
27 @implementation Foo : Object
28 - (char *)customString {
29   return cString;
30 }
31 @end
32
33
34 int main () {
35   Foo *string = @"bla";
36   {
37     Foo *string2 = @"bla";
38
39
40     if(string != string2)
41       abort();
42     printf("Strings are being uniqued properly\n");
43    }
44   return 0;
45 }
46