Tighten condition in vect/pr85586.c (PR 85654)
[official-gcc.git] / gcc / testsuite / gcc.dg / lvalue-2.c
blob7f9372f30e2d8db2ecec4a3575901cc7bbc856e0
1 /* Test diagnostic messages for invalid lvalues and non-modifiable
2 lvalues. */
3 /* Origin: Joseph Myers <jsm@polyomino.org.uk> */
4 /* { dg-do compile } */
5 /* { dg-options "" } */
7 int a, b;
9 void
10 f0 (void)
12 (a+b) = 1; /* { dg-error "lvalue required as left operand of assignment" } */
13 (a+b)++; /* { dg-error "lvalue required as increment operand" } */
14 ++(a+b); /* { dg-error "lvalue required as increment operand" } */
15 (a+b)--; /* { dg-error "lvalue required as decrement operand" } */
16 --(a+b); /* { dg-error "lvalue required as decrement operand" } */
17 &(a+b); /* { dg-error "lvalue required as unary '&' operand" } */
20 const int c;
21 const struct { int x; } d;
22 struct { const int x; } e;
23 const int *f;
25 void
26 f1 (void)
28 c = 1; /* { dg-error "assignment of read-only variable 'c'" } */
29 d.x = 1; /* { dg-error "assignment of member 'x' in read-only object" } */
30 e.x = 1; /* { dg-error "assignment of read-only member 'x'" } */
31 *f = 1; /* { dg-error "assignment of read-only location" } */
32 c++; /* { dg-error "increment of read-only variable 'c'" } */
33 d.x++; /* { dg-error "increment of member 'x' in read-only object" } */
34 e.x++; /* { dg-error "increment of read-only member 'x'" } */
35 (*f)++; /* { dg-error "increment of read-only location" } */
36 ++c; /* { dg-error "increment of read-only variable 'c'" } */
37 ++d.x; /* { dg-error "increment of member 'x' in read-only object" } */
38 ++e.x; /* { dg-error "increment of read-only member 'x'" } */
39 ++(*f); /* { dg-error "increment of read-only location" } */
40 c--; /* { dg-error "decrement of read-only variable 'c'" } */
41 d.x--; /* { dg-error "decrement of member 'x' in read-only object" } */
42 e.x--; /* { dg-error "decrement of read-only member 'x'" } */
43 (*f)--; /* { dg-error "decrement of read-only location" } */
44 --c; /* { dg-error "decrement of read-only variable 'c'" } */
45 --d.x; /* { dg-error "decrement of member 'x' in read-only object" } */
46 --e.x; /* { dg-error "decrement of read-only member 'x'" } */
47 --(*f); /* { dg-error "decrement of read-only location" } */