OSDN Git Service

In gcc/:
[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 scopes. */
2 /* Developed by Andrew Pinski <pinskia@physics.uc.edu> */
3 /* { dg-options "-fconstant-string-class=Foo " } */
4 /* { dg-do run } */
5
6 #include "../objc-obj-c++-shared/Object1.h"
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10
11 @interface Foo: Object {
12   char *cString;
13   unsigned int len;
14 }
15 - (char *)customString;
16 @end
17
18 #ifndef NEXT_OBJC_USE_NEW_INTERFACE
19 struct objc_class _FooClassReference;
20 #else
21 Class _FooClassReference;
22 #endif
23
24 @implementation Foo : Object
25 - (char *)customString {
26   return cString;
27 }
28 @end
29
30 int main () {
31   Foo *string = @"bla";
32   {
33     Foo *string2 = @"bla";
34
35     if(string != string2)
36       abort();
37     printf("Strings are being uniqued properly\n");
38    }
39   return 0;
40 }
41
42 #include "../objc-obj-c++-shared/Object1-implementation.h"