Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s |
Sebastian Redl | 50de12f | 2009-03-24 22:27:57 +0000 | [diff] [blame] | 2 | |
| 3 | int i = delete; // expected-error {{only functions can have deleted definitions}} |
| 4 | |
| 5 | void fn() = delete; // expected-note {{candidate function has been explicitly deleted}} |
| 6 | |
| 7 | void fn2(); // expected-note {{previous declaration is here}} |
| 8 | void fn2() = delete; // expected-error {{deleted definition must be first declaration}} |
| 9 | |
| 10 | void fn3() = delete; |
| 11 | void fn3() { |
| 12 | // FIXME: This definition should be invalid. |
| 13 | } |
| 14 | |
| 15 | void ov(int) {} // expected-note {{candidate function}} |
| 16 | void ov(double) = delete; // expected-note {{candidate function has been explicitly deleted}} |
| 17 | |
Sebastian Redl | e2b6833 | 2009-04-12 17:16:29 +0000 | [diff] [blame] | 18 | struct WithDel { |
Douglas Gregor | 745880f | 2009-12-20 22:01:25 +0000 | [diff] [blame^] | 19 | WithDel() = delete; // expected-note {{function has been explicitly marked deleted here}} |
Sebastian Redl | e2b6833 | 2009-04-12 17:16:29 +0000 | [diff] [blame] | 20 | void fn() = delete; // expected-note {{function has been explicitly marked deleted here}} |
Eli Friedman | cfdc81a | 2009-12-19 08:11:05 +0000 | [diff] [blame] | 21 | operator int() = delete; // expected-note {{function has been explicitly marked deleted here}} |
Sebastian Redl | e2b6833 | 2009-04-12 17:16:29 +0000 | [diff] [blame] | 22 | void operator +(int) = delete; |
Sebastian Redl | 0b5e7fb | 2009-04-12 17:41:24 +0000 | [diff] [blame] | 23 | |
| 24 | int i = delete; // expected-error {{only functions can have deleted definitions}} |
Sebastian Redl | e2b6833 | 2009-04-12 17:16:29 +0000 | [diff] [blame] | 25 | }; |
| 26 | |
Sebastian Redl | 50de12f | 2009-03-24 22:27:57 +0000 | [diff] [blame] | 27 | void test() { |
| 28 | fn(); // expected-error {{call to deleted function 'fn'}} |
| 29 | ov(1); |
| 30 | ov(1.0); // expected-error {{call to deleted function 'ov'}} |
Sebastian Redl | e2b6833 | 2009-04-12 17:16:29 +0000 | [diff] [blame] | 31 | |
Douglas Gregor | 745880f | 2009-12-20 22:01:25 +0000 | [diff] [blame^] | 32 | WithDel dd; // expected-error {{call to deleted constructor of 'struct WithDel'}} |
Sebastian Redl | e2b6833 | 2009-04-12 17:16:29 +0000 | [diff] [blame] | 33 | WithDel *d = 0; |
| 34 | d->fn(); // expected-error {{attempt to use a deleted function}} |
Eli Friedman | cfdc81a | 2009-12-19 08:11:05 +0000 | [diff] [blame] | 35 | int i = *d; // expected-error {{invokes a deleted function}} |
Sebastian Redl | 50de12f | 2009-03-24 22:27:57 +0000 | [diff] [blame] | 36 | } |