Richard Smith | 4c163a0 | 2013-05-17 02:19:35 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++11 %s -verify |
| 2 | |
| 3 | // expected-no-diagnostics |
| 4 | |
| 5 | namespace PR15757 { |
| 6 | struct S { |
| 7 | }; |
| 8 | |
| 9 | template<typename X, typename Y> struct T { |
| 10 | template<typename A> T(X x, A &&a) {} |
| 11 | |
| 12 | template<typename A> explicit T(A &&a) |
| 13 | noexcept(noexcept(T(X(), static_cast<A &&>(a)))) |
| 14 | : T(X(), static_cast<A &&>(a)) {} |
| 15 | }; |
| 16 | |
| 17 | template<typename X, typename Y> struct U : T<X, Y> { |
| 18 | using T<X, Y>::T; |
| 19 | }; |
| 20 | |
| 21 | U<S, char> foo(char ch) { return U<S, char>(ch); } |
| 22 | |
| 23 | int main() { |
| 24 | U<S, int> a(42); |
| 25 | U<S, char> b('4'); |
| 26 | return 0; |
| 27 | } |
| 28 | } |
Richard Smith | 09d5b3a | 2014-05-01 00:35:04 +0000 | [diff] [blame] | 29 | |
| 30 | namespace WrongIdent { |
| 31 | struct A {}; |
| 32 | struct B : A {}; |
| 33 | struct C : B { |
| 34 | using B::A; |
| 35 | }; |
| 36 | } |
Richard Smith | 5179eb7 | 2016-06-28 19:03:57 +0000 | [diff] [blame] | 37 | |
| 38 | namespace DefaultCtorConflict { |
| 39 | struct A { A(int = 0); }; |
| 40 | struct B : A { |
| 41 | using A::A; |
| 42 | } b; // ok, not ambiguous, inherited constructor suppresses implicit default constructor |
| 43 | struct C { |
| 44 | B b; |
| 45 | } c; |
| 46 | } |
Richard Smith | 80a4702 | 2016-06-29 01:10:27 +0000 | [diff] [blame] | 47 | |
| 48 | namespace InvalidConstruction { |
| 49 | struct A { A(int); }; |
| 50 | struct B { B() = delete; }; |
| 51 | struct C : A, B { using A::A; }; |
| 52 | // Initialization here is performed as if by a defaulted default constructor, |
| 53 | // which would be ill-formed (in the immediate context) in this case because |
| 54 | // it would be defined as deleted. |
| 55 | template<typename T> void f(decltype(T(0))*); |
| 56 | template<typename T> int &f(...); |
| 57 | int &r = f<C>(0); |
| 58 | } |