Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CXX / dcl.dcl / basic.namespace / namespace.udecl / p18.cpp
blobb9fca4bd5b616fc969f2fe6a231287c029bafb1b
1 // RUN: %clang_cc1 -std=c++11 -verify %s
3 struct Public {} public_;
4 struct Protected {} protected_;
5 struct Private {} private_;
7 class A {
8 public:
9 A(Public);
10 void f(Public);
12 protected:
13 A(Protected); // expected-note {{protected here}}
14 void f(Protected);
16 private:
17 A(Private); // expected-note 4{{private here}}
18 void f(Private); // expected-note {{private here}}
20 friend void Friend();
23 class B : private A {
24 using A::A; // ok
25 using A::f; // expected-error {{private member}}
27 void f() {
28 B a(public_);
29 B b(protected_);
30 B c(private_); // expected-error {{private}}
33 B(Public p, int) : B(p) {}
34 B(Protected p, int) : B(p) {}
35 B(Private p, int) : B(p) {} // expected-error {{private}}
38 class C : public B {
39 C(Public p) : B(p) {}
40 // There is no access check on the conversion from derived to base here;
41 // protected constructors of A act like protected constructors of B.
42 C(Protected p) : B(p) {}
43 C(Private p) : B(p) {} // expected-error {{private}}
46 void Friend() {
47 // There is no access check on the conversion from derived to base here.
48 B a(public_);
49 B b(protected_);
50 B c(private_);
53 void NonFriend() {
54 B a(public_);
55 B b(protected_); // expected-error {{protected}}
56 B c(private_); // expected-error {{private}}
59 namespace ProtectedAccessFromMember {
60 namespace a {
61 struct ES {
62 private:
63 ES(const ES &) = delete;
64 protected:
65 ES(const char *);
68 namespace b {
69 struct DES : a::ES {
70 DES *f();
71 private:
72 using a::ES::ES;
75 b::DES *b::DES::f() { return new b::DES("foo"); }