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