Debian Codegraph @

gcc/testsuite/g++.dg/template/permissive-error1b.C

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