testsuite: skip attr-retain-?.c on AIX
[official-gcc.git] / gcc / testsuite / objc.dg / property / dotsyntax-20.m
blobf1dd48e612e0f6d9d6f233bbd1ef9adaa9ecd1f5
1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
2 /* { dg-do compile } */
3 /* { dg-options "-Wall" } */
5 /* Test warnings with the dot-syntax.  */
7 #include <stdlib.h>
8 #include <objc/objc.h>
9 #include <objc/runtime.h>
11 @interface MyRootClass
13   Class isa;
14   id a;
15   id b;
16   int p1;
17   int p2;
19 + (id) initialize;
20 + (id) alloc;
21 - (id) init;
23 @property int p1;
24 @property int p2;
25 @end
27 @implementation MyRootClass
28 + (id) initialize { return self; }
29 + (id) alloc { return class_createInstance (self, 0); }
30 - (id) init { return self; }
31 @synthesize p1;
32 @synthesize p2;
33 @end
35 int main (void)
37   MyRootClass *object = [[MyRootClass alloc] init];
39   /* First, test that the artificial code generated by dot-syntax does
40      not generate unexpected warnings.  */
42   /* All of the following should generate no warnings.  */
43   object.p1 = 0;
44   object.p2 = 0;
45   object.p1 = object.p2 = 0;
46   if (object.p1 > 0)
47     object.p2 = 0;
48   
49   object.p1++;
50   ++object.p1;
51   object.p1--;
52   --object.p1;
53   
54   while (object.p1)
55     object.p1--;
57   /* Now test some warnings.  */
58   object.p1; /* { dg-warning "value computed is not used" } */
60   /* TODO: It would be good to get the following to warn.  */
61   if (object.p1 = 0) /* dg-warning "suggest parentheses around assignment used as truth value" */
62     abort ();
64   return 0;