diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-11-13 23:14:53 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-11-13 23:14:53 +0000 |
commit | cad84b7c12564ff37feb66d6d004bb609bea8788 (patch) | |
tree | afab19a2565e6069b475747c8b4946490d59d94a /test/SemaTemplate/constructor-template.cpp | |
parent | 65d0e28583ac050ec9aa71b469285faad48d137e (diff) |
A constructor template cannot be instantiated to a copy
constructor. Make sure that such declarations can never be formed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88718 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaTemplate/constructor-template.cpp')
-rw-r--r-- | test/SemaTemplate/constructor-template.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/test/SemaTemplate/constructor-template.cpp b/test/SemaTemplate/constructor-template.cpp index 79bf7c585e..f059766356 100644 --- a/test/SemaTemplate/constructor-template.cpp +++ b/test/SemaTemplate/constructor-template.cpp @@ -1,5 +1,4 @@ // RUN: clang-cc -fsyntax-only -verify %s - struct X0 { // expected-note{{candidate}} X0(int); // expected-note{{candidate}} template<typename T> X0(T); @@ -52,3 +51,22 @@ template<class C> struct A {}; template <> struct A<int>{A(const A<int>&);}; struct B { A<int> x; B(B& a) : x(a.x) {} }; +struct X2 { + X2(); + X2(X2&); + template<typename T> X2(T, int = 17); +}; + +X2 test(bool Cond, X2 x2) { + if (Cond) + return x2; // okay, uses copy constructor + + return X2(); // expected-error{{incompatible type}} +} + +struct X3 { + template<typename T> X3(T); +}; + +template<> X3::X3(X3); // expected-error{{no function template matches}} + |