blob: 6a8965ceb5786d964754cb4bb9ab2f99d82fe69a [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
Sebastian Redl50de12f2009-03-24 22:27:57 +00002
3int i = delete; // expected-error {{only functions can have deleted definitions}}
4
5void fn() = delete; // expected-note {{candidate function has been explicitly deleted}}
6
7void fn2(); // expected-note {{previous declaration is here}}
8void fn2() = delete; // expected-error {{deleted definition must be first declaration}}
9
Sean Hunt10620eb2011-05-06 20:44:56 +000010void fn3() = delete; // expected-note {{previous definition is here}}
11void fn3() { // expected-error {{redefinition}}
Sebastian Redl50de12f2009-03-24 22:27:57 +000012}
13
14void ov(int) {} // expected-note {{candidate function}}
15void ov(double) = delete; // expected-note {{candidate function has been explicitly deleted}}
16
Sebastian Redle2b68332009-04-12 17:16:29 +000017struct WithDel {
Douglas Gregor745880f2009-12-20 22:01:25 +000018 WithDel() = delete; // expected-note {{function has been explicitly marked deleted here}}
Sebastian Redle2b68332009-04-12 17:16:29 +000019 void fn() = delete; // expected-note {{function has been explicitly marked deleted here}}
Eli Friedmancfdc81a2009-12-19 08:11:05 +000020 operator int() = delete; // expected-note {{function has been explicitly marked deleted here}}
Sebastian Redle2b68332009-04-12 17:16:29 +000021 void operator +(int) = delete;
Sebastian Redl0b5e7fb2009-04-12 17:41:24 +000022
23 int i = delete; // expected-error {{only functions can have deleted definitions}}
Sebastian Redle2b68332009-04-12 17:16:29 +000024};
25
Sebastian Redl50de12f2009-03-24 22:27:57 +000026void test() {
27 fn(); // expected-error {{call to deleted function 'fn'}}
28 ov(1);
29 ov(1.0); // expected-error {{call to deleted function 'ov'}}
Sebastian Redle2b68332009-04-12 17:16:29 +000030
John McCall7c2342d2010-03-10 11:27:22 +000031 WithDel dd; // expected-error {{call to deleted constructor of 'WithDel'}}
Sebastian Redle2b68332009-04-12 17:16:29 +000032 WithDel *d = 0;
33 d->fn(); // expected-error {{attempt to use a deleted function}}
Eli Friedmancfdc81a2009-12-19 08:11:05 +000034 int i = *d; // expected-error {{invokes a deleted function}}
Sebastian Redl50de12f2009-03-24 22:27:57 +000035}