destructor.cpp revision 5f4a6829dc58cab2f76e2b98492859aa3b91e3f2
142a552f8200ba5948661aee0106fce0c04e39818Douglas Gregor// RUN: clang -fsyntax-only -verify %s 242a552f8200ba5948661aee0106fce0c04e39818Douglas Gregorclass A { 342a552f8200ba5948661aee0106fce0c04e39818Douglas Gregorpublic: 442a552f8200ba5948661aee0106fce0c04e39818Douglas Gregor ~A(); 542a552f8200ba5948661aee0106fce0c04e39818Douglas Gregor}; 642a552f8200ba5948661aee0106fce0c04e39818Douglas Gregor 742a552f8200ba5948661aee0106fce0c04e39818Douglas Gregorclass B { 842a552f8200ba5948661aee0106fce0c04e39818Douglas Gregorpublic: 942a552f8200ba5948661aee0106fce0c04e39818Douglas Gregor ~B() { } 1042a552f8200ba5948661aee0106fce0c04e39818Douglas Gregor}; 1142a552f8200ba5948661aee0106fce0c04e39818Douglas Gregor 1242a552f8200ba5948661aee0106fce0c04e39818Douglas Gregorclass C { 1342a552f8200ba5948661aee0106fce0c04e39818Douglas Gregorpublic: 1442a552f8200ba5948661aee0106fce0c04e39818Douglas Gregor (~C)() { } 1542a552f8200ba5948661aee0106fce0c04e39818Douglas Gregor}; 1642a552f8200ba5948661aee0106fce0c04e39818Douglas Gregor 1742a552f8200ba5948661aee0106fce0c04e39818Douglas Gregorstruct D { 1842a552f8200ba5948661aee0106fce0c04e39818Douglas Gregor static void ~D(int, ...) const { } // \ 1942a552f8200ba5948661aee0106fce0c04e39818Douglas Gregor // expected-error{{type qualifier is not allowed on this function}} \ 2042a552f8200ba5948661aee0106fce0c04e39818Douglas Gregor // expected-error{{destructor cannot be declared 'static'}} \ 2142a552f8200ba5948661aee0106fce0c04e39818Douglas Gregor // expected-error{{destructor cannot have a return type}} \ 2242a552f8200ba5948661aee0106fce0c04e39818Douglas Gregor // expected-error{{destructor cannot have any parameters}} \ 2342a552f8200ba5948661aee0106fce0c04e39818Douglas Gregor // expected-error{{destructor cannot be variadic}} 2442a552f8200ba5948661aee0106fce0c04e39818Douglas Gregor}; 2542a552f8200ba5948661aee0106fce0c04e39818Douglas Gregor 2642a552f8200ba5948661aee0106fce0c04e39818Douglas Gregorstruct E; 2742a552f8200ba5948661aee0106fce0c04e39818Douglas Gregor 2842a552f8200ba5948661aee0106fce0c04e39818Douglas Gregortypedef E E_typedef; 2942a552f8200ba5948661aee0106fce0c04e39818Douglas Gregorstruct E { 3042a552f8200ba5948661aee0106fce0c04e39818Douglas Gregor ~E_typedef(); // expected-error{{destructor cannot be declared using a typedef 'E_typedef' of the class name}} 3142a552f8200ba5948661aee0106fce0c04e39818Douglas Gregor}; 3242a552f8200ba5948661aee0106fce0c04e39818Douglas Gregor 3342a552f8200ba5948661aee0106fce0c04e39818Douglas Gregorstruct F { 345f4a6829dc58cab2f76e2b98492859aa3b91e3f2Chris Lattner (~F)(); // expected-note {{previous declaration is here}} 355f4a6829dc58cab2f76e2b98492859aa3b91e3f2Chris Lattner ~F(); // expected-error {{destructor cannot be redeclared}} 3642a552f8200ba5948661aee0106fce0c04e39818Douglas Gregor}; 3742a552f8200ba5948661aee0106fce0c04e39818Douglas Gregor 38c7ed9c60b8ee04b119e23441cae2cfec74536ba9Argyrios Kyrtzidis~; // expected-error {{expected class name}} 39c7ed9c60b8ee04b119e23441cae2cfec74536ba9Argyrios Kyrtzidis~undef(); // expected-error {{expected class name}} 40c7ed9c60b8ee04b119e23441cae2cfec74536ba9Argyrios Kyrtzidis~F(){} // expected-error {{destructor must be a non-static member function}} 41