/* APPLE LOCAL file Objective-C++ */ /* Further template tests; also, make sure that -fconstant-cfstrings does not interfere with ObjC message dispatch type-checking. */ /* Author: Ziemowit Laski . */ /* { dg-do run } */ /* { dg-options "-fconstant-cfstrings -framework Foundation -lstdc++" } */ #import extern void abort(void); #define CHECK_IF(expr) if(!(expr)) abort() template class TestT { public: TYPE k; int abc( ARR *array ) { return [array count] * k; } TestT(TYPE _k): k(_k) { } }; template NSString *getDesc(void) { return [TYPE description]; } template int abc( TYPE *xyz, NSArray *array ) { return [xyz count] + [array count]; } int main(void) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; CHECK_IF(![@"NSArray" compare: getDesc()]); NSArray* a1 = [NSArray arrayWithObjects:@"One", @"Two", @"Three", nil]; NSArray* a2 = [NSArray arrayWithObjects:@"Four", @"Five", nil]; TestT t(7); CHECK_IF(t.abc(a1) + t.abc(a2) == 35); CHECK_IF(abc(a1, a2) * t.k == 35); [pool release]; return 0; }