xref: /minix3/external/bsd/llvm/dist/clang/test/SemaTemplate/delegating-constructors.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc namespace PR10457 {
4*f4a2713aSLionel Sambuc 
5*f4a2713aSLionel Sambuc   class string
6*f4a2713aSLionel Sambuc   {
7*f4a2713aSLionel Sambuc     string(const char* str, unsigned);
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc   public:
10*f4a2713aSLionel Sambuc     template <unsigned N>
string(const char (& str)[N])11*f4a2713aSLionel Sambuc     string(const char (&str)[N])
12*f4a2713aSLionel Sambuc       : string(str) {} // expected-error{{constructor for 'string<6>' creates a delegation cycle}}
13*f4a2713aSLionel Sambuc   };
14*f4a2713aSLionel Sambuc 
f()15*f4a2713aSLionel Sambuc   void f() {
16*f4a2713aSLionel Sambuc     string s("hello");
17*f4a2713aSLionel Sambuc   }
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc   struct Foo {
FooPR10457::Foo20*f4a2713aSLionel Sambuc    Foo(int) { }
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc 
23*f4a2713aSLionel Sambuc    template <typename T>
FooPR10457::Foo24*f4a2713aSLionel Sambuc    Foo(T, int i) : Foo(i) { }
25*f4a2713aSLionel Sambuc };
26*f4a2713aSLionel Sambuc 
test_Foo()27*f4a2713aSLionel Sambuc   void test_Foo()
28*f4a2713aSLionel Sambuc   {
29*f4a2713aSLionel Sambuc     Foo f(1, 1);
30*f4a2713aSLionel Sambuc   }
31*f4a2713aSLionel Sambuc }
32*f4a2713aSLionel Sambuc 
33*f4a2713aSLionel Sambuc namespace PR12890 {
34*f4a2713aSLionel Sambuc   class Document
35*f4a2713aSLionel Sambuc   {
36*f4a2713aSLionel Sambuc   public:
37*f4a2713aSLionel Sambuc       Document() = default;
38*f4a2713aSLionel Sambuc 
39*f4a2713aSLionel Sambuc       template <class T>
40*f4a2713aSLionel Sambuc       explicit
Document(T && t)41*f4a2713aSLionel Sambuc       Document(T&& t) : Document()
42*f4a2713aSLionel Sambuc       {
43*f4a2713aSLionel Sambuc       }
44*f4a2713aSLionel Sambuc   };
f()45*f4a2713aSLionel Sambuc   void f()
46*f4a2713aSLionel Sambuc   {
47*f4a2713aSLionel Sambuc       Document d(1);
48*f4a2713aSLionel Sambuc   }
49*f4a2713aSLionel Sambuc }
50