1 /* Author: Ziemowit Laski <zlaski@apple.com>. */
4 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
5 /* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */
6 /* { dg-additional-sources "../objc-obj-c++-shared/nsconstantstring-class-impl.mm" } */
7 // { dg-additional-options "-Wno-objc-root-class" }
13 #ifndef __NEXT_RUNTIME__
14 #include <objc/NXConstStr.h>
16 #include "../objc-obj-c++-shared/nsconstantstring-class.h"
19 #include "../objc-obj-c++-shared/TestsuiteObject.m"
20 #include "../objc-obj-c++-shared/runtime.h"
22 #define CHECK_IF(expr) if(!(expr)) abort()
24 template <class ARR, class TYPE> class TestT
29 return [array count] * k;
31 TestT(TYPE _k): k(_k) { }
35 const char *getDesc(void) {
42 int abc(TYPE *xyz, Array *array) {
43 return [xyz count] + [array count];
46 @interface Array: TestsuiteObject {
50 + (id)arrayWithObjects:(id)first, ... ;
55 + (id)arrayWithObjects:(id)first, ... {
56 Array *a = [Array new];
58 a->arr = (id *) calloc(8, sizeof(id));
61 va_start (args, first);
63 a->arr[a->count++] = first;
65 for (id el; el = va_arg(args, id); a->count++)
66 a->arr[a->count] = el;
76 CHECK_IF(!strcmp ([@"TestsuiteObject" cString], getDesc<TestsuiteObject>()));
77 CHECK_IF(!strcmp ([@"Array" cString], getDesc<Array>()));
79 Array* a1 = [Array arrayWithObjects:@"One", @"Two", @"Three", nil];
80 Array* a2 = [Array arrayWithObjects:@"Four", @"Five", nil];
82 TestT<Array, int> t(7);
83 CHECK_IF(t.abc(a1) + t.abc(a2) == 35);
84 CHECK_IF(abc(a1, a2) * t.k == 35);