gcc/testsuite/g++.dg/lookup/this2.C
raw| 1 | // PR c++/106969 |
| 2 | // { dg-do compile { target c++11 } } |
| 3 | |
| 4 | struct Context |
| 5 | { |
| 6 | void |
| 7 | action() const |
| 8 | { |
| 9 | struct Foo |
| 10 | { |
| 11 | int wrapped; |
| 12 | decltype(&wrapped) get() { return &wrapped; } |
| 13 | } t; |
| 14 | |
| 15 | *t.get()= 42; // OK, get() returns int* not const int* |
| 16 | |
| 17 | struct Bar |
| 18 | { |
| 19 | using type = decltype(this); // { dg-error "invalid use of 'this'" } |
| 20 | }; |
| 21 | } |
| 22 | }; |