2009-12-15 23:14:24 +03:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
|
2009-03-25 01:27:57 +03:00
|
|
|
|
|
|
|
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}}
|
|
|
|
|
2009-04-12 21:16:29 +04:00
|
|
|
struct WithDel {
|
2009-12-21 01:01:25 +03:00
|
|
|
WithDel() = delete; // expected-note {{function has been explicitly marked deleted here}}
|
2009-04-12 21:16:29 +04:00
|
|
|
void fn() = delete; // expected-note {{function has been explicitly marked deleted here}}
|
2009-12-19 11:11:05 +03:00
|
|
|
operator int() = delete; // expected-note {{function has been explicitly marked deleted here}}
|
2009-04-12 21:16:29 +04:00
|
|
|
void operator +(int) = delete;
|
2009-04-12 21:41:24 +04:00
|
|
|
|
|
|
|
int i = delete; // expected-error {{only functions can have deleted definitions}}
|
2009-04-12 21:16:29 +04:00
|
|
|
};
|
|
|
|
|
2009-03-25 01:27:57 +03:00
|
|
|
void test() {
|
|
|
|
fn(); // expected-error {{call to deleted function 'fn'}}
|
|
|
|
ov(1);
|
|
|
|
ov(1.0); // expected-error {{call to deleted function 'ov'}}
|
2009-04-12 21:16:29 +04:00
|
|
|
|
2010-03-10 14:27:22 +03:00
|
|
|
WithDel dd; // expected-error {{call to deleted constructor of 'WithDel'}}
|
2009-04-12 21:16:29 +04:00
|
|
|
WithDel *d = 0;
|
|
|
|
d->fn(); // expected-error {{attempt to use a deleted function}}
|
2009-12-19 11:11:05 +03:00
|
|
|
int i = *d; // expected-error {{invokes a deleted function}}
|
2009-03-25 01:27:57 +03:00
|
|
|
}
|