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" } */
12 #ifndef __NEXT_RUNTIME__
13 #include <objc/NXConstStr.h>
15 #include "../objc-obj-c++-shared/nsconstantstring-class.h"
18 #include "../objc-obj-c++-shared/TestsuiteObject.m"
19 #include "../objc-obj-c++-shared/runtime.h"
21 #define CHECK_IF(expr) if(!(expr)) abort()
23 template <class ARR, class TYPE> class TestT
28 return [array count] * k;
30 TestT(TYPE _k): k(_k) { }
34 const char *getDesc(void) {
41 int abc(TYPE *xyz, Array *array) {
42 return [xyz count] + [array count];
45 @interface Array: TestsuiteObject {
49 + (id)arrayWithObjects:(id)first, ... ;
54 + (id)arrayWithObjects:(id)first, ... {
55 Array *a = [Array new];
57 a->arr = (id *) calloc(8, sizeof(id));
60 va_start (args, first);
62 a->arr[a->count++] = first;
64 for (id el; el = va_arg(args, id); a->count++)
65 a->arr[a->count] = el;
75 CHECK_IF(!strcmp ([@"TestsuiteObject" cString], getDesc<TestsuiteObject>()));
76 CHECK_IF(!strcmp ([@"Array" cString], getDesc<Array>()));
78 Array* a1 = [Array arrayWithObjects:@"One", @"Two", @"Three", nil];
79 Array* a2 = [Array arrayWithObjects:@"Four", @"Five", nil];
81 TestT<Array, int> t(7);
82 CHECK_IF(t.abc(a1) + t.abc(a2) == 35);
83 CHECK_IF(abc(a1, a2) * t.k == 35);