Merged r157653 through r157895 into branch.
[official-gcc.git] / gcc / testsuite / obj-c++.dg / const-str-7.mm
blob755b0452be20a3cefe2678f67191825c91ccef04
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> */
5 /* { dg-options "-fconstant-string-class=Foo" } */
6 /* { dg-do run } */
7 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
9 #include "../objc-obj-c++-shared/Object1.h"
10 #include "../objc-obj-c++-shared/next-mapping.h"
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <memory.h>
14 #include <objc/objc.h>
16 @interface Foo: Object {
17   char *cString;
18   unsigned int len;
20 - (char *)customString;
21 @end
23 #ifdef NEXT_OBJC_USE_NEW_INTERFACE
24 struct fudge_objc_class _FooClassReference;
25 #else
26 struct objc_class _FooClassReference;
27 #endif
29 @implementation Foo : Object
30 - (char *)customString {
31   return cString;
33 @end
36 int main () {
37   Foo *string = @"bla";
38   {
39     Foo *string2 = @"bla";
41     if(string != string2)
42       abort();
43     printf("Strings are being uniqued properly\n");
44    }
45   return 0;
47 #include "../objc-obj-c++-shared/Object1-implementation.h"