| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-additional-options "-Wno-objc-root-class" } */ |
| 3 |
|
| 4 |
/* Test deprecate attribute with an @interface declaration. */ |
| 5 |
|
| 6 |
#include <objc/objc.h> |
| 7 |
|
| 8 |
__attribute__ ((deprecated)) |
| 9 |
@interface DeprecatedClass |
| 10 |
{ |
| 11 |
Class isa; |
| 12 |
} |
| 13 |
+ (id) classObject; |
| 14 |
+ (id) new; |
| 15 |
@end |
| 16 |
|
| 17 |
@implementation DeprecatedClass |
| 18 |
+ (id) classObject { return self; } |
| 19 |
+ (id) new { return nil; } |
| 20 |
@end |
| 21 |
|
| 22 |
@interface DeprecatedClass (Category) |
| 23 |
@end /* { dg-warning "is deprecated" } */ |
| 24 |
|
| 25 |
@interface Subclass : DeprecatedClass |
| 26 |
@end /* { dg-warning "is deprecated" } */ |
| 27 |
|
| 28 |
DeprecatedClass *object; /* { dg-warning "is deprecated" } */ |
| 29 |
|
| 30 |
int function (DeprecatedClass *object) /* { dg-warning "is deprecated" } */ |
| 31 |
{ |
| 32 |
/* Note how the following deprecation warning is generated by |
| 33 |
"DeprecatedClass *", not by "[DeprecatedClass ...]. */ |
| 34 |
DeprecatedClass *x = [DeprecatedClass new]; /* { dg-warning "is deprecated" } */ |
| 35 |
|
| 36 |
if (x == object) |
| 37 |
return 0; |
| 38 |
else |
| 39 |
return 1; |
| 40 |
} |
| 41 |
|
| 42 |
id function2 (void) |
| 43 |
{ |
| 44 |
return DeprecatedClass.classObject; /* { dg-warning "is deprecated" } */ |
| 45 |
} |
| 46 |
|
| 47 |
@interface NormalClass |
| 48 |
{ |
| 49 |
Class isa; |
| 50 |
DeprecatedClass *object; /* { dg-warning "is deprecated" } */ |
| 51 |
} |
| 52 |
- (DeprecatedClass *)method; /* { dg-warning "is deprecated" } */ |
| 53 |
@end |
| 54 |
|
| 55 |
@implementation NormalClass |
| 56 |
- (DeprecatedClass *)method /* { dg-warning "is deprecated" } */ |
| 57 |
{ |
| 58 |
return nil; |
| 59 |
} |
| 60 |
@end |