PR target/83368
[official-gcc.git] / gcc / testsuite / obj-c++.dg / attributes / class-attribute-1.mm
blobf078339b86705ce5b7a89019fd64e6988950d2c2
1 /* { dg-do compile } */
2 /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
4 /* Test deprecate attribute with an @interface declaration.  */
6 #include <objc/objc.h>
7 #include <objc/runtime.h>
9 __attribute__ ((deprecated)) 
10 @interface DeprecatedClass
12   Class isa;
14 + (id) classObject;
15 + (id) new;
16 @end
18 @implementation DeprecatedClass
19 + (id) classObject { return self; }
20 + (id) new { return nil; }
21 @end
23 @interface DeprecatedClass (Category) /* { dg-warning "is deprecated" } */
24 @end
26 @interface Subclass : DeprecatedClass /* { dg-warning "is deprecated" } */
27 @end
29 DeprecatedClass *object; /* { dg-warning "is deprecated" } */
31 int function (DeprecatedClass *object) /* { dg-warning "is deprecated" } */
33   /* Note how the following deprecation warning is generated by
34      "DeprecatedClass *", not by "[DeprecatedClass ...].  */
35   DeprecatedClass *x = [DeprecatedClass new]; /* { dg-warning "is deprecated" } */
37   if (x == object)
38     return 0;
39   else
40     return 1;
43 id function2 (void)
45   return DeprecatedClass.classObject; /* { dg-warning "is deprecated" } */
48 @interface NormalClass
50   Class isa;
51   DeprecatedClass *object; /* { dg-warning "is deprecated" } */
53 - (DeprecatedClass *)method; /* { dg-warning "is deprecated" } */
54 @end
56 @implementation NormalClass
57 - (DeprecatedClass *)method /* { dg-warning "is deprecated" } */
59   return nil;
61 @end