| 1 |
// PR c++/116064 |
| 2 |
// { dg-additional-options -fpermissive } |
| 3 |
// Like permissive-error1.C but verify instantiating the errorneous |
| 4 |
// templates gives an error after all. |
| 5 |
|
| 6 |
template<class T> |
| 7 |
void f() { // { dg-error "instantiating erroneous template" } |
| 8 |
const int n = 42; |
| 9 |
++n; // { dg-warning "read-only variable 'n' .-Wtemplate-body." } |
| 10 |
// { dg-message "first error appeared here" "" { target *-*-* } .-1 } |
| 11 |
// { dg-error "read-only variable 'n'\[\n\r\]" "" { target *-*-* } .-2 } |
| 12 |
} |
| 13 |
|
| 14 |
template<class T> |
| 15 |
struct A { |
| 16 |
void f(typename A::type); // { dg-warning "does not name a type" } |
| 17 |
}; |
| 18 |
|
| 19 |
template<class T> |
| 20 |
struct B { |
| 21 |
void f() { |
| 22 |
this->g(); // { dg-warning "no member" } |
| 23 |
} |
| 24 |
}; |
| 25 |
|
| 26 |
int main() { |
| 27 |
f<int>(); // { dg-message "required from here" } |
| 28 |
A<int> a; |
| 29 |
B<int> b; |
| 30 |
b.f(); |
| 31 |
} |