Debian Codegraph @

gcc/testsuite/g++.dg/template/friend84.C

raw
1 // PR c++/118255
2 // { dg-do "compile" }
3
4 // The PR's case, that used to error out.
5 template <int non_template>
6 struct S {
7 friend class non_template; // { dg-bogus "shadows template parameter" }
8 };
9
10 class non_template {};
11 S<0> s;
12
13 // We already accepted cases where the friend is already declared.
14 template <int non_template>
15 struct T {
16 friend class non_template;
17 };
18 T<0> t;
19
20 // We should reject (re)declarations.
21 template <int non_template>
22 struct U {
23 class non_template {}; // { dg-error "shadows template parameter" }
24 void non_template () {} // { dg-error "shadows template parameter" }
25 };
26 U<0> u;