OSDN Git Service

83bc1c02468cfff2abe015d915df3cf63e2b235f
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / objc.dg / attributes / method-attribute-1.m
1 /* { dg-do compile } */
2
3 #include <objc/objc.h>
4 #include "../../objc-obj-c++-shared/Object1.h"
5
6 @interface obj : Object {
7 @public 
8   int var; 
9
10 - (int) mth;
11 + (id) dep_cls_mth __attribute__((deprecated)) ;/* { dg-warning "method attributes are not available in this version" } */
12 - (int) dep_ins_mth __attribute__((deprecated)) ;/* { dg-warning "method attributes are not available in this version" } */
13 - (int) dep_ins_mtharg: (int) i __attribute__((deprecated)) ;/* { dg-warning "method attributes are not available in this version" } */
14 - (int) dep_ins_mtharg1: (int) i __attribute__((deprecated)) add: (int) j;/* { dg-error "expected ';' or '\{' after method attribute definition" } */
15 - (int) nodef __attribute__((deprecated)) { return var-2; } ; /* { dg-error "expected ';' before '\{' token" } */
16 __attribute__((deprecated))
17 - (int) bad_pref_mth; /* { dg-warning "prefix attributes are ignored for methods" } */
18 @end
19
20 @implementation obj
21 - (int) mth { return var; }
22 + (id) dep_cls_mth { return self; }
23 - (int) dep_ins_mth  { return var ; }
24 - (int) dep_ins_mtharg: (int) i { return var + i ; }
25 - (int) dep_ins_mtharg1: (int) i add: (int) j { return var + i + j ; } 
26 - (int) bad_pref_mth { return var; };
27 - (int) nodef { return var-2; } ; 
28 @end 
29
30 int foo (void)
31 {
32   obj *p = [obj new];
33   id n = [obj dep_cls_mth];
34   
35   [p dep_ins_mth];
36   [p dep_ins_mtharg:2];
37   [p dep_ins_mtharg1:3 add:3];
38
39   return [p mth];    
40 }