diff options
author | Douglas Gregor <dgregor@apple.com> | 2008-11-05 15:29:30 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2008-11-05 15:29:30 +0000 |
commit | f03d7c7af2ca8555c513ba7667acffb667445ecd (patch) | |
tree | ccbec86bd811939366a570861a353ef170d69763 /test | |
parent | 7ad8390f7992ab7f19b1460c5f0b9d96f165c4e9 (diff) |
Implement C++ copy-initialization for declarations. There is now some
duplication in the handling of copy-initialization by constructor,
which occurs both for initialization of a declaration and for
overloading. The initialization code is due for some refactoring.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58756 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/SemaCXX/copy-initialization.cpp | 17 | ||||
-rw-r--r-- | test/SemaCXX/direct-initializer.cpp | 6 |
2 files changed, 20 insertions, 3 deletions
diff --git a/test/SemaCXX/copy-initialization.cpp b/test/SemaCXX/copy-initialization.cpp new file mode 100644 index 0000000000..17028da069 --- /dev/null +++ b/test/SemaCXX/copy-initialization.cpp @@ -0,0 +1,17 @@ +// RUN: clang -fsyntax-only -verify %s + +class X { +public: + explicit X(const X&); + X(int*); // expected-note{{candidate function}} + explicit X(float*); +}; + +class Y : public X { }; + +void f(Y y, int *ip, float *fp) { + X x1 = y; // expected-error{{no matching constructor for initialization of 'x1'; candidates are:}} + X x2 = 0; + X x3 = ip; + X x4 = fp; // expected-error{{incompatible type initializing 'x4', expected 'class X'}} +} diff --git a/test/SemaCXX/direct-initializer.cpp b/test/SemaCXX/direct-initializer.cpp index 952e132299..d5b91bb2b7 100644 --- a/test/SemaCXX/direct-initializer.cpp +++ b/test/SemaCXX/direct-initializer.cpp @@ -20,9 +20,9 @@ public: X(float, Y); // expected-note{{candidate function}} }; -class Z { // expected-note{{candidate function}} +class Z { public: - Z(int); // expected-note{{candidate function}} + Z(int); }; void g() { @@ -32,5 +32,5 @@ void g() { Y y(1.0); X x4(3.14, y); - Z z; // expected-error{{no matching constructor for initialization of 'z'; candidates are:}} + Z z; // expected-error{{no matching constructor for initialization of 'z'}} } |