1 /* Author: Ziemowit Laski <zlaski@apple.com>. */
4 /* { dg-skip-if "" { *-*-darwin* } { "-m64" } { "" } } */
6 #include <objc/Object.h>
10 #ifdef __NEXT_RUNTIME__
11 /* The following ain't pretty, but does allow us to have just one copy
13 #include "../objc/execute/next_mapping.h"
15 #include <objc/NXConstStr.h>
18 #define CHECK_IF(expr) if(!(expr)) abort()
20 template <class ARR, class TYPE> class TestT
25 return [array count] * k;
27 TestT(TYPE _k): k(_k) { }
31 const char *getDesc(void) {
38 int abc(TYPE *xyz, Array *array) {
39 return [xyz count] + [array count];
42 @interface Array: Object {
46 + (id)arrayWithObjects:(id)first, ... ;
51 + (id)arrayWithObjects:(id)first, ... {
52 Array *a = [Array new];
54 a->arr = (id *) calloc(8, sizeof(id));
57 va_start (args, first);
59 a->arr[a->count++] = first;
61 for (id el; el = va_arg(args, id); a->count++)
62 a->arr[a->count] = el;
72 CHECK_IF(!strcmp ([@"Object" cString], getDesc<Object>()));
73 CHECK_IF(!strcmp ([@"Array" cString], getDesc<Array>()));
75 Array* a1 = [Array arrayWithObjects:@"One", @"Two", @"Three", nil];
76 Array* a2 = [Array arrayWithObjects:@"Four", @"Five", nil];
78 TestT<Array, int> t(7);
79 CHECK_IF(t.abc(a1) + t.abc(a2) == 35);
80 CHECK_IF(abc(a1, a2) * t.k == 35);