gcc/testsuite/g++.dg/cpp0x/decltype-pr81506.C
raw| 1 | // PR c++/81506 - Invalid declaration with decltype accepted |
| 2 | // { dg-do compile } |
| 3 | // |
| 4 | |
| 5 | #if __cplusplus < 201103L |
| 6 | # define decltype __typeof__ |
| 7 | #endif |
| 8 | |
| 9 | template <int> |
| 10 | struct A |
| 11 | { |
| 12 | A () { |
| 13 | decltype (this); // { dg-error "declaration does not declare anything" } |
| 14 | } |
| 15 | }; |
| 16 | |
| 17 | A<0> a; |
| 18 | |
| 19 | template <class> |
| 20 | struct B |
| 21 | { |
| 22 | B () { |
| 23 | __typeof__ (this); // { dg-error "declaration does not declare anything" } |
| 24 | } |
| 25 | }; |
| 26 | |
| 27 | B<int> b; |
| 28 |