diff options
Diffstat (limited to 'gcc/testsuite/objc.dg/instancetype-0.m')
-rw-r--r-- | gcc/testsuite/objc.dg/instancetype-0.m | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/gcc/testsuite/objc.dg/instancetype-0.m b/gcc/testsuite/objc.dg/instancetype-0.m new file mode 100644 index 00000000000..32cafdf314c --- /dev/null +++ b/gcc/testsuite/objc.dg/instancetype-0.m @@ -0,0 +1,30 @@ +/* Contributed by Iain Sandoe <iain@sandoe.co.uk>, May 2019. */ +/* { dg-do compile } */ + +/* Basic check of parsing instancetype. */ + +extern id class_createInstance (id, int); +extern id class_getSuperclass (id); + +@interface MyObject +{ + Class isa; +} ++ (instancetype)alloc; +- (instancetype)init; ++ (instancetype)initialize; ++ (instancetype)factoryMethodA; ++ (id)factoryMethodB; ++ (Class) class; ++ (Class) superclass; +@end + +@implementation MyObject ++ (instancetype)alloc { return class_createInstance (self, 0); } +- (instancetype)init { return self; } ++ (instancetype)initialize { return self; } ++ (instancetype)factoryMethodA { return [[[self class] alloc] init]; } ++ (id)factoryMethodB { return [[[self class] alloc] init]; } ++ (Class) class { return self; } ++ (Class) superclass { return class_getSuperclass (self); } +@end |