gcc/testsuite/g++.old-deja/g++.mike/p701.C
raw| 1 | // { dg-do assemble } |
| 2 | // prms-id: 701 |
| 3 | |
| 4 | extern "C" |
| 5 | { |
| 6 | int printf(const char *, ...); |
| 7 | } |
| 8 | |
| 9 | |
| 10 | void Munge(int& x) // { dg-message "argument 1" } |
| 11 | { |
| 12 | x = 2; |
| 13 | } |
| 14 | |
| 15 | |
| 16 | class A |
| 17 | { |
| 18 | public: |
| 19 | int i; |
| 20 | A(int x) : i(x) {} |
| 21 | void Safe() const; |
| 22 | }; |
| 23 | |
| 24 | void |
| 25 | A::Safe() const |
| 26 | { |
| 27 | Munge(i); // { dg-error "const" } |
| 28 | } |
| 29 | |
| 30 | int main() |
| 31 | { |
| 32 | const A a(1); |
| 33 | a.Safe(); |
| 34 | } |