1/* Test if ObjC constant string layout is checked properly, regardless of how
2   constant string classes get derived.  */
3/* Contributed by Ziemowit Laski <zlaski@apple.com>  */
4
5/* { dg-do compile { target *-*-darwin* } } */
6/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
7/* { dg-options "-fconstant-string-class=XStr" } */
8/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=XStr" { target *-*-darwin* } } */
9
10#include "../../../objc-obj-c++-shared/F-NSObject.h"
11#include "../../../objc-obj-c++-shared/runtime.h" /* For NEXT_OBJC_USE_NEW_INTERFACE.  */
12
13@interface XString: NSObject {
14@protected
15    char *bytes;
16}
17@end
18
19@interface XStr : XString {
20@public
21    unsigned int len;
22}
23@end
24
25#ifndef NEXT_OBJC_USE_NEW_INTERFACE
26extern struct objc_class _XStrClassReference;
27#else
28extern Class _XStrClassReference;
29#endif
30
31const XStr *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__XStrClassReference\n\t.long\t.*\n\t.long\t5\n\t.data"  { target { *-*-darwin* && { ! lp64 } } } } } */
36/* { dg-final { scan-assembler ".quad\t_OBJC_CLASS_._XStr\n\t.quad\t.*\n\t.long\t5\n\t.space" { target { *-*-darwin* && { lp64 } } } } } */
37