OSDN Git Service

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