aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-11-13 23:14:53 +0000
committerDouglas Gregor <dgregor@apple.com>2009-11-13 23:14:53 +0000
commitcad84b7c12564ff37feb66d6d004bb609bea8788 (patch)
treeafab19a2565e6069b475747c8b4946490d59d94a /test
parent65d0e28583ac050ec9aa71b469285faad48d137e (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')
-rw-r--r--test/SemaCXX/constructor-recovery.cpp7
-rw-r--r--test/SemaCXX/copy-constructor-error.cpp8
-rw-r--r--test/SemaTemplate/constructor-template.cpp20
-rw-r--r--test/SemaTemplate/operator-template.cpp6
4 files changed, 29 insertions, 12 deletions
diff --git a/test/SemaCXX/constructor-recovery.cpp b/test/SemaCXX/constructor-recovery.cpp
index 50fdc9622e..f2f9f43a10 100644
--- a/test/SemaCXX/constructor-recovery.cpp
+++ b/test/SemaCXX/constructor-recovery.cpp
@@ -1,10 +1,9 @@
// RUN: clang-cc -fsyntax-only -verify %s
-struct C { // expected-note {{candidate function}}
- virtual C() = 0; // expected-error{{constructor cannot be declared 'virtual'}} \
- expected-note {{candidate function}}
+struct C {
+ virtual C() = 0; // expected-error{{constructor cannot be declared 'virtual'}}
};
void f() {
- C c; // expected-error {{call to constructor of 'c' is ambiguous}}
+ C c;
}
diff --git a/test/SemaCXX/copy-constructor-error.cpp b/test/SemaCXX/copy-constructor-error.cpp
index 2e42fcc3b1..c50a1579bb 100644
--- a/test/SemaCXX/copy-constructor-error.cpp
+++ b/test/SemaCXX/copy-constructor-error.cpp
@@ -1,13 +1,11 @@
// RUN: clang-cc -fsyntax-only -verify %s
-struct S { // expected-note {{candidate function}}
- S (S); // expected-error {{copy constructor must pass its first argument by reference}} \\
- // expected-note {{candidate function}}
+struct S {
+ S (S); // expected-error {{copy constructor must pass its first argument by reference}}
};
S f();
void g() {
- S a( f() ); // expected-error {{call to constructor of 'a' is ambiguous}}
+ S a( f() ); // expected-error {{no matching constructor}}
}
-
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}}
+
diff --git a/test/SemaTemplate/operator-template.cpp b/test/SemaTemplate/operator-template.cpp
index 7039e0ec83..af01a10042 100644
--- a/test/SemaTemplate/operator-template.cpp
+++ b/test/SemaTemplate/operator-template.cpp
@@ -11,6 +11,8 @@ int a0(A<int> x) { return x == 1; }
template<class X>struct B{typedef X Y;};
template<class X>bool operator==(B<X>*,typename B<X>::Y); // \
expected-error{{overloaded 'operator==' must have at least one parameter of class or enumeration type}} \
-expected-note{{in instantiation of member function}}
-int a(B<int> x) { return operator==(&x,1); }
+expected-note{{in instantiation of function template specialization}}
+int a(B<int> x) {
+ return operator==(&x,1); // expected-error{{no matching function}}
+}