diff options
author | ed <ed@FreeBSD.org> | 2009-06-02 17:58:47 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2009-06-02 17:58:47 +0000 |
commit | f27e5a09a0d815b8a4814152954ff87dadfdefc0 (patch) | |
tree | ce7d964cbb5e39695b71481698f10cb099c23d4a /test/SemaCXX/copy-assignment.cpp | |
download | FreeBSD-src-f27e5a09a0d815b8a4814152954ff87dadfdefc0.zip FreeBSD-src-f27e5a09a0d815b8a4814152954ff87dadfdefc0.tar.gz |
Import Clang, at r72732.
Diffstat (limited to 'test/SemaCXX/copy-assignment.cpp')
-rw-r--r-- | test/SemaCXX/copy-assignment.cpp | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/test/SemaCXX/copy-assignment.cpp b/test/SemaCXX/copy-assignment.cpp new file mode 100644 index 0000000..6e5012f --- /dev/null +++ b/test/SemaCXX/copy-assignment.cpp @@ -0,0 +1,99 @@ +// RUN: clang-cc -fsyntax-only -verify %s +struct A { +}; + +struct ConvertibleToA { + operator A(); +}; + +struct ConvertibleToConstA { + operator const A(); +}; + +struct B { + B& operator=(B&); +}; + +struct ConvertibleToB { + operator B(); +}; + +struct ConvertibleToBref { + operator B&(); +}; + +struct ConvertibleToConstB { + operator const B(); +}; + +struct ConvertibleToConstBref { + operator const B&(); +}; + +struct C { + int operator=(int); // expected-note{{candidate function}} + long operator=(long); // expected-note{{candidate function}} + int operator+=(int); // expected-note{{candidate function}} + int operator+=(long); // expected-note{{candidate function}} +}; + +struct D { + D& operator+=(const D &); +}; + +struct ConvertibleToInt { + operator int(); +}; + +void test() { + A a, na; + const A constA; + ConvertibleToA convertibleToA; + ConvertibleToConstA convertibleToConstA; + + B b, nb; + const B constB; + ConvertibleToB convertibleToB; + ConvertibleToBref convertibleToBref; + ConvertibleToConstB convertibleToConstB; + ConvertibleToConstBref convertibleToConstBref; + + C c, nc; + const C constC; + + D d, nd; + const D constD; + + ConvertibleToInt convertibleToInt; + + na = a; + na = constA; + na = convertibleToA; + na = convertibleToConstA; + na += a; // expected-error{{no viable overloaded '+='}} + + nb = b; + nb = constB; // expected-error{{no viable overloaded '='}} + nb = convertibleToB; // expected-error{{no viable overloaded '='}} + nb = convertibleToBref; + nb = convertibleToConstB; // expected-error{{no viable overloaded '='}} + nb = convertibleToConstBref; // expected-error{{no viable overloaded '='}} + + nc = c; + nc = constC; + nc = 1; + nc = 1L; + nc = 1.0; // expected-error{{use of overloaded operator '=' is ambiguous}} + nc += 1; + nc += 1L; + nc += 1.0; // expected-error{{use of overloaded operator '+=' is ambiguous}} + + nd = d; + nd += d; + nd += constD; + + int i; + i = convertibleToInt; + i = a; // expected-error{{incompatible type assigning 'struct A', expected 'int'}} +} + |