OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [obj-c++.dg/] [property/] [dotsyntax-20.mm] - Blame information for rev 703

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 703 jeremybenn
/* Contributed by Nicola Pero , November 2010.  */
2
/* { dg-do compile } */
3
/* { dg-options "-Wall" } */
4
 
5
/* Test warnings with the dot-syntax.  */
6
 
7
#include 
8
#include 
9
#include 
10
 
11
@interface MyRootClass
12
{
13
  Class isa;
14
  id a;
15
  id b;
16
  int p1;
17
  int p2;
18
}
19
+ (id) initialize;
20
+ (id) alloc;
21
- (id) init;
22
 
23
@property int p1;
24
@property int p2;
25
@end
26
 
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
34
 
35
int main (void)
36
{
37
  MyRootClass *object = [[MyRootClass alloc] init];
38
 
39
  /* First, test that the artificial code generated by dot-syntax does
40
     not generate unexpected warnings.  */
41
 
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--;
56
 
57
  /* Now test some warnings.  */
58
  object.p1; /* This warning does not seem to be produced in C++.  dg-warning "value computed is not used" */
59
 
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 ();
63
 
64
  return 0;
65
}
66
 
67
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.