[ARM,testsuite] Skip tests incompatible with -mpure-code.
[gcc.git] / gcc / testsuite / obj-c++.dg / template-1.mm
1 /* Test for using ObjC classes as C++ template parameters. */
2 /* Author: Ziemowit Laski <zlaski@apple.com>. */
3
4 /* { dg-do run } */
5 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
6 #include "../objc-obj-c++-shared/TestsuiteObject.m"
7 #include <stdlib.h>
8
9 #define CHECK_IF(expr) if(!(expr)) abort()
10
11 @interface Base: TestsuiteObject
12 - (int) meth;
13 @end
14
15 @interface Derived: Base
16 - (int) meth;
17 @end
18
19 static int count = 0;
20
21 template <class T> struct Templ
22 {
23 T *m;
24 int i;
25 Templ(): i(55), m([[T alloc] init]) { count++; }
26 ~Templ() { [m free]; count--; }
27 };
28
29 @implementation Base
30 - (int) meth { return 333; }
31 @end
32
33 @implementation Derived
34 - (int) meth { return 666; }
35 @end
36
37 int main (void) {
38 CHECK_IF(count == 0);
39 {
40 Templ<Derived> derived;
41 CHECK_IF(derived.i == 55 && count == 1);
42 Templ<Base> base;
43 CHECK_IF(base.i == 55 && count == 2);
44 CHECK_IF([base.m meth] == 333);
45 CHECK_IF([derived.m meth] == 666);
46 }
47 CHECK_IF(count == 0);
48 return 0;
49 }
50