gcc/testsuite/g++.dg/conversion/access1.C
raw| 1 | // PR c++/38579 |
| 2 | |
| 3 | struct P |
| 4 | { |
| 5 | protected: |
| 6 | P() {} |
| 7 | P(const P&) {} |
| 8 | }; |
| 9 | |
| 10 | struct B : protected P |
| 11 | { |
| 12 | B() {} |
| 13 | }; |
| 14 | |
| 15 | struct C : public P |
| 16 | { |
| 17 | // C can access P's copy ctor, but can't convert b to const P&. |
| 18 | C(const B& b) : P(b) {} // { dg-error "inaccessible base" } |
| 19 | }; |
| 20 | |
| 21 | void foo() |
| 22 | { |
| 23 | B b; |
| 24 | C c(b); |
| 25 | } |