OSDN Git Service

2010-03-25 Iain Sandoe <iain.sandoe@sandoe-acoustics.co.uk>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / obj-c++.dg / const-str-7.mm
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 /* { dg-options "-fconstant-string-class=Foo" } */
6 /* { dg-do run } */
7
8 #include "../objc-obj-c++-shared/Object1.h"
9 #include "../objc-obj-c++-shared/next-mapping.h"
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <memory.h>
13 #include <objc/objc.h>
14
15 @interface Foo: Object {
16   char *cString;
17   unsigned int len;
18 }
19 - (char *)customString;
20 @end
21
22 #ifdef NEXT_OBJC_USE_NEW_INTERFACE
23 struct fudge_objc_class _FooClassReference;
24 #else
25 struct objc_class _FooClassReference;
26 #endif
27
28 @implementation Foo : Object
29 - (char *)customString {
30   return cString;
31 }
32 @end
33
34
35 int main () {
36   Foo *string = @"bla";
37   {
38     Foo *string2 = @"bla";
39
40     if(string != string2)
41       abort();
42     printf("Strings are being uniqued properly\n");
43    }
44   return 0;
45 }
46 #include "../objc-obj-c++-shared/Object1-implementation.h"