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/deleted-function.cpp | |
download | FreeBSD-src-f27e5a09a0d815b8a4814152954ff87dadfdefc0.zip FreeBSD-src-f27e5a09a0d815b8a4814152954ff87dadfdefc0.tar.gz |
Import Clang, at r72732.
Diffstat (limited to 'test/SemaCXX/deleted-function.cpp')
-rw-r--r-- | test/SemaCXX/deleted-function.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/SemaCXX/deleted-function.cpp b/test/SemaCXX/deleted-function.cpp new file mode 100644 index 0000000..8064ed3 --- /dev/null +++ b/test/SemaCXX/deleted-function.cpp @@ -0,0 +1,36 @@ +// RUN: clang-cc -fsyntax-only -verify -std=c++0x %s + +int i = delete; // expected-error {{only functions can have deleted definitions}} + +void fn() = delete; // expected-note {{candidate function has been explicitly deleted}} + +void fn2(); // expected-note {{previous declaration is here}} +void fn2() = delete; // expected-error {{deleted definition must be first declaration}} + +void fn3() = delete; +void fn3() { + // FIXME: This definition should be invalid. +} + +void ov(int) {} // expected-note {{candidate function}} +void ov(double) = delete; // expected-note {{candidate function has been explicitly deleted}} + +struct WithDel { + WithDel() = delete; // expected-note {{candidate function has been explicitly deleted}} + void fn() = delete; // expected-note {{function has been explicitly marked deleted here}} + operator int() = delete; + void operator +(int) = delete; + + int i = delete; // expected-error {{only functions can have deleted definitions}} +}; + +void test() { + fn(); // expected-error {{call to deleted function 'fn'}} + ov(1); + ov(1.0); // expected-error {{call to deleted function 'ov'}} + + WithDel dd; // expected-error {{call to deleted constructor of 'dd'}} + WithDel *d = 0; + d->fn(); // expected-error {{attempt to use a deleted function}} + int i = *d; // expected-error {{incompatible type initializing}} +} |