1 /* Author: Ziemowit Laski <zlaski@apple.com>. */
4 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
5 #include "../objc-obj-c++-shared/Object1.h"
6 #include "../objc-obj-c++-shared/next-mapping.h"
10 #ifndef __NEXT_RUNTIME__
11 #include <objc/NXConstStr.h>
14 #define CHECK_IF(expr) if(!(expr)) abort()
16 template <class ARR, class TYPE> class TestT
21 return [array count] * k;
23 TestT(TYPE _k): k(_k) { }
27 const char *getDesc(void) {
34 int abc(TYPE *xyz, Array *array) {
35 return [xyz count] + [array count];
38 @interface Array: Object {
42 + (id)arrayWithObjects:(id)first, ... ;
47 + (id)arrayWithObjects:(id)first, ... {
48 Array *a = [Array new];
50 a->arr = (id *) calloc(8, sizeof(id));
53 va_start (args, first);
55 a->arr[a->count++] = first;
57 for (id el; el = va_arg(args, id); a->count++)
58 a->arr[a->count] = el;
68 CHECK_IF(!strcmp ([@"Object" cString], getDesc<Object>()));
69 CHECK_IF(!strcmp ([@"Array" cString], getDesc<Array>()));
71 Array* a1 = [Array arrayWithObjects:@"One", @"Two", @"Three", nil];
72 Array* a2 = [Array arrayWithObjects:@"Four", @"Five", nil];
74 TestT<Array, int> t(7);
75 CHECK_IF(t.abc(a1) + t.abc(a2) == 35);
76 CHECK_IF(abc(a1, a2) * t.k == 35);
79 #include "../objc-obj-c++-shared/Object1-implementation.h"