1// Check if ObjC classes with non-POD C++ ivars are specially marked in the metadata.
2
3// { dg-do run { target *-*-darwin* } }
4// { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } }
5// { dg-skip-if "Headers incompatible with 10.4 APIs" { *-*-darwin1[3-8]* } { "-fnext-runtime" } { "" } }
6// { dg-additional-options "-fobjc-call-cxx-cdtors -mmacosx-version-min=10.4 -framework Foundation" }
7// This test has no equivalent or meaning for m64/ABI V2
8// { dg-xfail-run-if "No Test Avail" {  *-*-darwin* && lp64 } { "-fnext-runtime" } { "" } }
9
10#include <objc/objc-runtime.h>
11#include <stdlib.h>
12#include "../objc-obj-c++-shared/F-NSObject.h"
13
14//extern "C" { int printf(const char *,...); }
15#define CHECK_IF(expr) if(!(expr)) abort()
16
17#ifndef CLS_HAS_CXX_STRUCTORS
18#define CLS_HAS_CXX_STRUCTORS 0x2000L
19#endif
20
21struct cxx_struct {
22  int a, b;
23  cxx_struct (void) { a = b = 55; }
24};
25
26@interface Foo: NSObject {
27  int c;
28  cxx_struct s;
29}
30@end
31
32@interface Bar: Foo {
33  float f;
34}
35@end
36
37@implementation Foo
38@end
39
40@implementation Bar
41@end
42
43int main (void)
44{
45#ifndef __LP64__
46  Class cls;
47
48  cls = objc_getClass("Foo");
49//  printf((const char *)"Foo info %lx\n",cls->info);
50  CHECK_IF((cls->info & CLS_HAS_CXX_STRUCTORS) != 0);
51  cls = objc_getClass("Bar");
52//  printf((const char *)"Bar info %lx\n",cls->info);
53  CHECK_IF((cls->info & CLS_HAS_CXX_STRUCTORS) == 0);
54
55#else
56  /* No test needed or available.  */
57  abort ();
58#endif
59  return 0;
60}
61