| 1 |
/* Test if ObjC constant string layout is checked properly, regardless of how |
| 2 |
constant string classes get derived. */ |
| 3 |
/* Contributed by Ziemowit Laski <[email protected]> */ |
| 4 |
|
| 5 |
/* { dg-do compile } */ |
| 6 |
/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ |
| 7 |
/* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */ |
| 8 |
|
| 9 |
#include "../../../objc-obj-c++-shared/F-NSObject.h" |
| 10 |
#include "../../../objc-obj-c++-shared/runtime.h" /* For NEXT_OBJC_USE_NEW_INTERFACE. */ |
| 11 |
|
| 12 |
@interface NSString: NSObject |
| 13 |
@end |
| 14 |
|
| 15 |
@interface NSSimpleCString : NSString { |
| 16 |
@protected |
| 17 |
char *bytes; |
| 18 |
unsigned int numBytes; |
| 19 |
} |
| 20 |
@end |
| 21 |
|
| 22 |
@interface NSConstantString : NSSimpleCString |
| 23 |
@end |
| 24 |
|
| 25 |
#ifdef NEXT_OBJC_USE_NEW_INTERFACE |
| 26 |
Class _NSConstantStringClassReference; |
| 27 |
#else |
| 28 |
extern struct objc_class _NSConstantStringClassReference; |
| 29 |
#endif |
| 30 |
|
| 31 |
const NSConstantString *appKey = @"MyApp"; |
| 32 |
|
| 33 |
/* { dg-final { scan-assembler ".section __OBJC, __cstring_object" { target { *-*-darwin* && { ! lp64 } } } } } */ |
| 34 |
/* { dg-final { scan-assembler ".section __DATA, __objc_stringobj" { target { *-*-darwin* && { lp64 } } } } } */ |
| 35 |
/* { dg-final { scan-assembler ".long\t__NSConstantStringClassReference\n\t.long\t.*\n\t.long\t5\n\t.data" { target { *-*-darwin* && { ! lp64 } } } } } */ |
| 36 |
/* { dg-final { scan-assembler ".quad\t_OBJC_CLASS_._NSConstantString\n\t.quad\t.*\n\t.long\t5\n\t.space" { target { *-*-darwin* && { lp64 } } } } } */ |