2007-03-01 Paul Brook <paul@codesourcery.com>
[official-gcc.git] / gcc / testsuite / objc.dg / const-str-7.m
blob3691579381d3a931b3697862998782ab77bc1cd5
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> */
6 /* { dg-options "-fnext-runtime -fconstant-string-class=Foo -lobjc" } */
7 /* { dg-do run { target *-*-darwin* } } */
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <memory.h>
13 #include <objc/objc.h>
14 #include <objc/Object.h>
17 @interface Foo: Object {
18   char *cString;
19   unsigned int len;
21 - (char *)customString;
22 @end
24 struct objc_class _FooClassReference;
27 @implementation Foo : Object
28 - (char *)customString {
29   return cString;
31 @end
34 int main () {
35   Foo *string = @"bla";
36   {
37     Foo *string2 = @"bla";
40     if(string != string2)
41       abort();
42     printf("Strings are being uniqued properly\n");
43    }
44   return 0;