gcc/testsuite/g++.old-deja/g++.jason/pmf7.C
raw| 1 | // { dg-do run } |
| 2 | // PRMS Id: 6486 |
| 3 | // Make sure that no confused handling of COND_EXPRs and SAVE_EXPRs messes |
| 4 | // with the number of calls to foo. |
| 5 | |
| 6 | int c; |
| 7 | |
| 8 | struct A { |
| 9 | void f () {} |
| 10 | virtual void g () {} |
| 11 | }; |
| 12 | |
| 13 | A& foo () |
| 14 | { |
| 15 | static A a; |
| 16 | ++c; |
| 17 | return a; |
| 18 | } |
| 19 | |
| 20 | int main () |
| 21 | { |
| 22 | void (A::*p)() = &A::f; |
| 23 | (foo ().*p)(); |
| 24 | p = &A::g; |
| 25 | (foo ().*p)(); |
| 26 | |
| 27 | return 2 - c; |
| 28 | } |