40 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s2 3// PR10127/N30314struct A { ~A(); };5struct B {};6template<typename T>7void b(const T *x, const A *y) {8 x->~decltype(T())();9 x->~decltype(*x)(); // expected-error{{the type of object expression ('const int') does not match the type being destroyed ('decltype(*x)' (aka 'const int &')) in pseudo-destructor expression}} \10 expected-error{{no member named '~const A &' in 'A'}}11 x->~decltype(int())(); // expected-error{{no member named '~int' in 'A'}}12 13 y->~decltype(*y)(); // expected-error{{destructor type 'decltype(*y)' (aka 'const A &') in object destruction expression does not match the type 'const A' of the object being destroyed}}14 y->~decltype(T())(); // expected-error{{destructor type 'decltype(T())' in object destruction expression does not match the type 'const A' of the object being destroyed}}15 y->~decltype(A())();16}17template void b(const int*, const A*); // expected-note{{in instantiation of function template specialization 'b<int>' requested here}}18template void b(const A*,const A*); // expected-note{{in instantiation of function template specialization 'b<A>' requested here}}19void a(const A *x, int i, int *pi) {20 x->~decltype(A())();21 x->~decltype(*x)(); // expected-error{{destructor type 'decltype(*x)' (aka 'const A &') in object destruction expression does not match the type 'const A' of the object being destroyed}}22 x->~decltype()(); // expected-error{{expected expression}}23 x->~decltype(B())(); // expected-error{{destructor type 'decltype(B())' (aka 'B') in object destruction expression does not match the type 'const A' of the object being destroyed}}24 x->~decltype(x)(); // expected-error{{destructor type 'decltype(x)' (aka 'const A *') in object destruction expression does not match the type 'const A' of the object being destroyed}}25 // this last one could be better, mentioning that the nested-name-specifier could be removed or a type name after the ~26 x->::A::~decltype(*x)(); // expected-error{{expected a class name after '~' to name a destructor}}27 y->~decltype(A())(); // expected-error{{use of undeclared identifier 'y'}}28 29 typedef int *intp;30 i->~decltype(int())(); // expected-error{{member reference type 'int' is not a pointer; did you mean to use '.'?}}31 i.~decltype(int())();32 i->~decltype(intp())(); // expected-error{{member reference type 'int' is not a pointer; did you mean to use '.'?}} \33 expected-error{{the type of object expression ('int') does not match the type being destroyed ('decltype(intp())' (aka 'int *')) in pseudo-destructor expression}}34 i.~decltype(intp())(); // expected-error{{the type of object expression ('int') does not match the type being destroyed ('decltype(intp())' (aka 'int *')) in pseudo-destructor expression}}35 pi->~decltype(int())();36 pi.~decltype(int())(); // expected-error{{member reference type 'int *' is a pointer; did you mean to use '->'?}}37 pi.~decltype(intp())();38 pi->~decltype(intp())(); // expected-error{{the type of object expression ('int') does not match the type being destroyed ('decltype(intp())' (aka 'int *')) in pseudo-destructor expression}}39}40