| 1 |
// PR c++/79377 |
| 2 |
// { dg-do run } |
| 3 |
// { dg-options "-fpermissive" } |
| 4 |
|
| 5 |
struct A |
| 6 |
{ |
| 7 |
A () : a (0) {} |
| 8 |
A& operator++ () { ++a; ++c; return *this; } |
| 9 |
int a; |
| 10 |
static int c; |
| 11 |
}; |
| 12 |
|
| 13 |
int A::c = 0; |
| 14 |
|
| 15 |
template <typename> |
| 16 |
void |
| 17 |
foo (A& a) |
| 18 |
{ |
| 19 |
a++; // { dg-warning "trying prefix operator instead" } |
| 20 |
if (A::c != 3 || a.a != 3) __builtin_abort (); |
| 21 |
++a; |
| 22 |
if (A::c != 4 || a.a != 4) __builtin_abort (); |
| 23 |
} |
| 24 |
|
| 25 |
int |
| 26 |
main () |
| 27 |
{ |
| 28 |
A a; |
| 29 |
if (A::c != 0 || a.a != 0) __builtin_abort (); |
| 30 |
++a; |
| 31 |
if (A::c != 1 || a.a != 1) __builtin_abort (); |
| 32 |
a++; // { dg-warning "trying prefix operator instead" } |
| 33 |
if (A::c != 2 || a.a != 2) __builtin_abort (); |
| 34 |
foo<int> (a); |
| 35 |
if (A::c != 4 || a.a != 4) __builtin_abort (); |
| 36 |
} |