block-no-trampoline.C [plain text]
#import <Foundation/NSObject.h>
#import <stdio.h>
extern "C" void abort(void);
extern "C" void __enable_execute_stack ()
{
abort();
}
@interface A : NSObject
- (int)bork:(int)i;
@end
@implementation A
- (int)bork:(int)i {
printf("i == %d\n", i);
return i + 37;
}
@end
@interface B : A
- (id)foo:(id)i;
@end
@implementation B
- (id)foo:(id)i {
printf("Hello world\n");
}
- (id)bar:(int)i {
int xnew;
[self foo:
^() {
__block int xnew;
xnew = [super bork:i];
}];
}
@end
int main() {
B *b = [[B alloc] init];
[b foo:0];
[b bar:0];
[b release];
return 0;
}