From 185be185b2cbf11fa78a121aa503e60b9271d13d Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 10 Apr 2013 05:48:59 +0000 Subject: C++11 inheriting constructors: support for inheriting constructor templates. llvm-svn: 179151 --- clang/test/CXX/special/class.inhctor/p2.cpp | 36 ++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'clang/test/CXX/special/class.inhctor/p2.cpp') diff --git a/clang/test/CXX/special/class.inhctor/p2.cpp b/clang/test/CXX/special/class.inhctor/p2.cpp index e4267385ced..e6abd6840e4 100644 --- a/clang/test/CXX/special/class.inhctor/p2.cpp +++ b/clang/test/CXX/special/class.inhctor/p2.cpp @@ -3,7 +3,7 @@ template struct X {}; // Constructor characteristics are: -// - the template parameter list [FIXME] +// - the template parameter list // - the parameter-type-list // - absence or presence of explicit // - absence or presence of constexpr @@ -85,3 +85,37 @@ struct ConstexprEval3 : ConstexprEval, ConstexprEval2 { constexpr ConstexprEval3 ce{4, "foobar"}; static_assert(ce.k == 'a', ""); static_assert(ce.k2 == 'x', ""); + + +struct TemplateCtors { + constexpr TemplateCtors() {} + template class T> TemplateCtors(X<0>, T<0>); + template TemplateCtors(X<1>, X); + template TemplateCtors(X<2>, T); + + template TemplateCtors(int, int = 0, int = 0); // expected-note {{inherited from here}} +}; + +struct UsingTemplateCtors : TemplateCtors { + using TemplateCtors::TemplateCtors; // expected-note 4{{here}} expected-note {{candidate}} + + constexpr UsingTemplateCtors(X<0>, X<0>) {} + constexpr UsingTemplateCtors(X<1>, X<1>) {} + constexpr UsingTemplateCtors(X<2>, X<2>) {} + + template constexpr UsingTemplateCtors(int) {} // expected-note {{candidate}} + template constexpr UsingTemplateCtors(int, int) {} + template constexpr UsingTemplateCtors(int, int, int) {} +}; + +template struct Y {}; +constexpr UsingTemplateCtors uct1{ X<0>{}, X<0>{} }; +constexpr UsingTemplateCtors uct2{ X<0>{}, Y<0>{} }; // expected-error {{must be initialized by a constant expression}} expected-note {{non-constexpr}} +constexpr UsingTemplateCtors uct3{ X<1>{}, X<0>{} }; // expected-error {{must be initialized by a constant expression}} expected-note {{non-constexpr}} +constexpr UsingTemplateCtors uct4{ X<1>{}, X<1>{} }; +constexpr UsingTemplateCtors uct5{ X<2>{}, 0 }; // expected-error {{must be initialized by a constant expression}} expected-note {{non-constexpr}} +constexpr UsingTemplateCtors uct6{ X<2>{}, X<2>{} }; + +constexpr UsingTemplateCtors utc7{ 0 }; // expected-error {{ambiguous}} +constexpr UsingTemplateCtors utc8{ 0, 0 }; // ok +constexpr UsingTemplateCtors utc9{ 0, 0, 0 }; // expected-error {{must be initialized by a constant expression}} expected-note {{non-constexpr}} -- cgit v1.2.3