1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -fcxx-exceptions %s 2f4a2713aSLionel Sambuc 3f4a2713aSLionel Sambuc int i = delete; // expected-error {{only functions can have deleted definitions}} 4f4a2713aSLionel Sambuc 5f4a2713aSLionel Sambuc void fn() = delete; // expected-note {{candidate function has been explicitly deleted}} 6f4a2713aSLionel Sambuc 7f4a2713aSLionel Sambuc void fn2(); // expected-note {{previous declaration is here}} 8f4a2713aSLionel Sambuc void fn2() = delete; // expected-error {{deleted definition must be first declaration}} 9f4a2713aSLionel Sambuc 10f4a2713aSLionel Sambuc void fn3() = delete; // expected-note {{previous definition is here}} fn3()11f4a2713aSLionel Sambucvoid fn3() { // expected-error {{redefinition}} 12f4a2713aSLionel Sambuc } 13f4a2713aSLionel Sambuc ov(int)14f4a2713aSLionel Sambucvoid ov(int) {} // expected-note {{candidate function}} 15f4a2713aSLionel Sambuc void ov(double) = delete; // expected-note {{candidate function has been explicitly deleted}} 16f4a2713aSLionel Sambuc 17f4a2713aSLionel Sambuc struct WithDel { 18*0a6a1f1dSLionel Sambuc WithDel() = delete; // expected-note {{'WithDel' has been explicitly marked deleted here}} 19*0a6a1f1dSLionel Sambuc void fn() = delete; // expected-note {{'fn' has been explicitly marked deleted here}} 20*0a6a1f1dSLionel Sambuc operator int() = delete; // expected-note {{'operator int' has been explicitly marked deleted here}} 21f4a2713aSLionel Sambuc void operator +(int) = delete; 22f4a2713aSLionel Sambuc 23f4a2713aSLionel Sambuc int i = delete; // expected-error {{only functions can have deleted definitions}} 24f4a2713aSLionel Sambuc }; 25f4a2713aSLionel Sambuc test()26f4a2713aSLionel Sambucvoid test() { 27f4a2713aSLionel Sambuc fn(); // expected-error {{call to deleted function 'fn'}} 28f4a2713aSLionel Sambuc ov(1); 29f4a2713aSLionel Sambuc ov(1.0); // expected-error {{call to deleted function 'ov'}} 30f4a2713aSLionel Sambuc 31f4a2713aSLionel Sambuc WithDel dd; // expected-error {{call to deleted constructor of 'WithDel'}} 32f4a2713aSLionel Sambuc WithDel *d = 0; 33f4a2713aSLionel Sambuc d->fn(); // expected-error {{attempt to use a deleted function}} 34f4a2713aSLionel Sambuc int i = *d; // expected-error {{invokes a deleted function}} 35f4a2713aSLionel Sambuc } 36f4a2713aSLionel Sambuc 37f4a2713aSLionel Sambuc struct DelDtor { 38f4a2713aSLionel Sambuc ~DelDtor() = delete; // expected-note 9{{here}} 39f4a2713aSLionel Sambuc }; f()40f4a2713aSLionel Sambucvoid f() { 41f4a2713aSLionel Sambuc DelDtor *p = new DelDtor[3]; // expected-error {{attempt to use a deleted function}} 42f4a2713aSLionel Sambuc delete [] p; // expected-error {{attempt to use a deleted function}} 43f4a2713aSLionel Sambuc const DelDtor &dd2 = DelDtor(); // expected-error {{attempt to use a deleted function}} 44f4a2713aSLionel Sambuc DelDtor dd; // expected-error {{attempt to use a deleted function}} 45f4a2713aSLionel Sambuc throw dd; // expected-error {{attempt to use a deleted function}} 46f4a2713aSLionel Sambuc } 47f4a2713aSLionel Sambuc struct X : DelDtor { ~XX48f4a2713aSLionel Sambuc ~X() {} // expected-error {{attempt to use a deleted function}} 49f4a2713aSLionel Sambuc }; 50f4a2713aSLionel Sambuc struct Y { 51f4a2713aSLionel Sambuc DelDtor dd; ~YY52f4a2713aSLionel Sambuc ~Y() {} // expected-error {{attempt to use a deleted function}} 53f4a2713aSLionel Sambuc }; 54f4a2713aSLionel Sambuc struct Z : virtual DelDtor { ~ZZ55f4a2713aSLionel Sambuc ~Z() {} // expected-error {{attempt to use a deleted function}} 56f4a2713aSLionel Sambuc }; 57f4a2713aSLionel Sambuc DelDtor dd; // expected-error {{attempt to use a deleted function}} 58f4a2713aSLionel Sambuc 59f4a2713aSLionel Sambuc template<typename> void test2() = delete; 60f4a2713aSLionel Sambuc template void test2<int>(); 61f4a2713aSLionel Sambuc 62f4a2713aSLionel Sambuc template<typename> void test3() = delete; 63f4a2713aSLionel Sambuc template<typename> void test3(); 64f4a2713aSLionel Sambuc template void test3<int>(); 65f4a2713aSLionel Sambuc test4()66f4a2713aSLionel Sambucvoid test4() {} // expected-note {{previous definition is here}} 67f4a2713aSLionel Sambuc void test4() = delete; // expected-error {{redefinition of 'test4'}} 68