| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 |
|
| 3 |
class M { |
| 4 |
int iM; |
| 5 |
}; |
| 6 |
|
| 7 |
class P { |
| 8 |
int iP; // expected-note {{declared private here}} |
| 9 |
int PPR(); // expected-note {{declared private here}} |
| 10 |
}; |
| 11 |
|
| 12 |
class N : M,P { |
| 13 |
N() {} |
| 14 |
int PR() { return iP + PPR(); } // expected-error 2 {{private member of 'P'}} |
| 15 |
}; |
| 16 |
|
| 17 |
namespace GH83608 { |
| 18 |
|
| 19 |
class single; |
| 20 |
|
| 21 |
class check_constructible { |
| 22 |
// This makes the class a non-aggregate, which enforces us to check |
| 23 |
// the constructor when initializing. |
| 24 |
check_constructible() {} |
| 25 |
|
| 26 |
friend class single; |
| 27 |
}; |
| 28 |
|
| 29 |
struct single { |
| 30 |
template <class T> single(T u, check_constructible = {}) {} |
| 31 |
}; |
| 32 |
|
| 33 |
// We perform access checking when substituting into the default argument. |
| 34 |
// Make sure it runs within the context of 'single'. |
| 35 |
single x(0); |
| 36 |
|
| 37 |
} |
| 38 |
|
| 39 |
namespace GH62444 { |
| 40 |
|
| 41 |
struct B { |
| 42 |
friend struct A; |
| 43 |
private: |
| 44 |
B(int); // #B |
| 45 |
}; |
| 46 |
|
| 47 |
template<class T> |
| 48 |
int f(T = 0); // #Decl |
| 49 |
|
| 50 |
struct A { |
| 51 |
A() { |
| 52 |
int i = f<B>(); |
| 53 |
// expected-error@#Decl {{calling a private constructor}} |
| 54 |
// expected-note@-2 {{in instantiation of default function argument}} |
| 55 |
// expected-note@#B {{declared private}} |
| 56 |
} |
| 57 |
}; |
| 58 |
|
| 59 |
int i = f<B>(); |
| 60 |
|
| 61 |
} |