summaryrefslogtreecommitdiff
path: root/clang/test/SemaCXX/deleted-function.cpp
diff options
context:
space:
mode:
authorCarlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au>2012-10-15 17:10:06 +1100
committerCarlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au>2012-10-15 17:10:06 +1100
commitbe1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch)
tree1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/SemaCXX/deleted-function.cpp
parentc4626a62754862d20b41e8a46a3574264ea80e6d (diff)
parentf1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff)
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/SemaCXX/deleted-function.cpp')
-rw-r--r--clang/test/SemaCXX/deleted-function.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/deleted-function.cpp b/clang/test/SemaCXX/deleted-function.cpp
new file mode 100644
index 0000000..d13fd0e
--- /dev/null
+++ b/clang/test/SemaCXX/deleted-function.cpp
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -fcxx-exceptions %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; // expected-note {{previous definition is here}}
+void fn3() { // expected-error {{redefinition}}
+}
+
+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 {{function has been explicitly marked deleted here}}
+ void fn() = delete; // expected-note {{function has been explicitly marked deleted here}}
+ operator int() = delete; // expected-note {{function has been explicitly marked deleted here}}
+ 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 'WithDel'}}
+ WithDel *d = 0;
+ d->fn(); // expected-error {{attempt to use a deleted function}}
+ int i = *d; // expected-error {{invokes a deleted function}}
+}
+
+struct DelDtor {
+ ~DelDtor() = delete; // expected-note 9{{here}}
+};
+void f() {
+ DelDtor *p = new DelDtor[3]; // expected-error {{attempt to use a deleted function}}
+ delete [] p; // expected-error {{attempt to use a deleted function}}
+ const DelDtor &dd2 = DelDtor(); // expected-error {{attempt to use a deleted function}}
+ DelDtor dd; // expected-error {{attempt to use a deleted function}}
+ throw dd; // expected-error {{attempt to use a deleted function}}
+}
+struct X : DelDtor {
+ ~X() {} // expected-error {{attempt to use a deleted function}}
+};
+struct Y {
+ DelDtor dd;
+ ~Y() {} // expected-error {{attempt to use a deleted function}}
+};
+struct Z : virtual DelDtor {
+ ~Z() {} // expected-error {{attempt to use a deleted function}}
+};
+DelDtor dd; // expected-error {{attempt to use a deleted function}}