Make the ObjC++ interop test compile

main
David Chisnall 8 years ago
parent 9760ae8d48
commit 1f2d35006b

@ -63,9 +63,12 @@ foreach(TEST_SOURCE ${TESTS})
get_filename_component(TEST ${TEST_SOURCE} NAME_WE) get_filename_component(TEST ${TEST_SOURCE} NAME_WE)
addtest_flags(${TEST} "-O0 -UNDEBUG" ${TEST_SOURCE}) addtest_flags(${TEST} "-O0 -UNDEBUG" ${TEST_SOURCE})
addtest_flags("${TEST}_optimised" "-O3 -UNDEBUG" ${TEST_SOURCE}) addtest_flags("${TEST}_optimised" "-O3 -UNDEBUG" ${TEST_SOURCE})
target_compile_definitions(${TEST} PRIVATE SINGLE_FILE_TEST=1)
target_compile_definitions("${TEST}_optimised" PRIVATE SINGLE_FILE_TEST=1)
endforeach() endforeach()
# Tests that are more than a single file. # Tests that are more than a single file.
addtest_flags(CXXExceptions "-O0" "CXXException.m;CXXException.cc") addtest_flags(CXXExceptions "-O0" "CXXException.m;CXXException.cc;Test.m")
addtest_flags(CXXExceptions_optimised "-O3" "CXXException.m;CXXException.cc") addtest_flags(CXXExceptions_optimised "-O3" "CXXException.m;CXXException.cc;Test.m")
addtest_flags(MinRep "-O0" "minRep1.mm;minRep2.mm;minRep.mm;minRepM.m;ModTest.m;MyException.m") addtest_flags(ObjCXXEHInterop "-O0" "minRep1.mm;minRep2.mm;minRep.mm;minRepM.m;MyException.m;Test.m")
addtest_flags(ObjCXXEHInterop_opttimised "-O3" "minRep1.mm;minRep2.mm;minRep.mm;minRepM.m;MyException.m;Test.m")

@ -1,4 +1,4 @@
#include "ModTest.h" #include "Test.h"
@interface MyException : Test { @interface MyException : Test {
@private @private

@ -1,21 +1,20 @@
#import "MyException.h" #import "MyException.h"
#include <stdlib.h>
@implementation MyException @implementation MyException
- (MyException *)initWithName:(char *)name - (MyException *)initWithName:(char *)name
reason:(char *)reason reason:(char *)reason
{ {
if ((self = [super init]) != nil) {
_name = name; _name = name;
_reason = reason; _reason = reason;
}
return self; return self;
} }
+ (void) raise: (char *)name + (void) raise: (char *)name
format: (char *)reason format: (char *)reason
{ {
MyException *e = [[[MyException alloc] initWithName:name MyException *e = [[[MyException new] initWithName:name
reason:reason] autorelease]; reason:reason] autorelease];
[e raise]; [e raise];
} }
@ -28,6 +27,7 @@
if (_reason) { if (_reason) {
free(_reason); free(_reason);
} }
[super dealloc];
} }
- (void) raise { - (void) raise {

@ -23,6 +23,11 @@ __attribute__((objc_root_class))
#endif #endif
@end @end
@interface NSAutoreleasePool : Test
@end
#ifdef SINGLE_FILE_TEST
#if !__has_feature(objc_arc) #if !__has_feature(objc_arc)
@implementation Test @implementation Test
+ (Class)class { return self; } + (Class)class { return self; }
@ -48,10 +53,7 @@ __attribute__((objc_root_class))
} }
- (void)_ARCCompliantRetainRelease {} - (void)_ARCCompliantRetainRelease {}
@end @end
#endif
@interface NSAutoreleasePool : Test
@end
@implementation NSAutoreleasePool @implementation NSAutoreleasePool
- (void)_ARCCompatibleAutoreleasePool {} - (void)_ARCCompatibleAutoreleasePool {}
+ (void)addObject:(id)anObject + (void)addObject:(id)anObject
@ -59,3 +61,6 @@ __attribute__((objc_root_class))
objc_autorelease(anObject); objc_autorelease(anObject);
} }
@end @end
#endif
#endif

@ -4,37 +4,7 @@
#undef NDEBUG #undef NDEBUG
#endif #endif
#include <assert.h> #include <assert.h>
#ifndef SINGLE_FILE_TEST
#ifndef __has_attribute #define SINGLE_FILE_TEST 1
#define __has_attribute(x) 0
#endif #endif
#include "Test.h"
#if __has_attribute(objc_root_class)
__attribute__((objc_root_class))
#endif
@interface Test { id isa; }
@end
@implementation Test
+ (Class)class { return self; }
+ (id)new
{
return class_createInstance(self, 0);
}
- (void)dealloc
{
object_dispose(self);
}
- (id)autorelease
{
return objc_autorelease(self);
}
- (id)retain
{
return objc_retain(self);
}
- (void)release
{
objc_release(self);
}
- (void)_ARCCompliantRetainRelease {}
@end

@ -1,4 +1,4 @@
#import "ModTest.h" #import "Test.h"
#import "minRepM.h" #import "minRepM.h"

@ -1,4 +1,4 @@
#import "ModTest.h" #import "Test.h"
#import "minRep2.h" #import "minRep2.h"

@ -1,4 +1,4 @@
#import "ModTest.h" #import "Test.h"
#import "minRep1.h" #import "minRep1.h"

@ -1,4 +1,4 @@
#import "ModTest.h" #import "Test.h"
@interface MinRep2 : Test { @interface MinRep2 : Test {
} }

@ -1,4 +1,4 @@
#import "ModTest.h" #import "Test.h"
#import "minRep2.h" #import "minRep2.h"
#import "MyException.h" #import "MyException.h"

@ -1,4 +1,4 @@
#import "ModTest.h" #import "Test.h"
#import "minRep1.h" #import "minRep1.h"

@ -1,4 +1,4 @@
#import "ModTest.h" #import "Test.h"
#import "minRepM.h" #import "minRepM.h"
#import "minRep1.h" #import "minRep1.h"

Loading…
Cancel
Save