From: David Blaikie Date: Mon, 12 Dec 2011 04:13:55 +0000 (+0000) Subject: Fix/test decltype dtor calls with invalid base expression. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4db8c4483ea7b271bcce3a0312a0ac434313c09b;p=clang Fix/test decltype dtor calls with invalid base expression. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146354 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index af297840c3..59369d603d 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -266,7 +266,7 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, } ParsedType Sema::getDestructorType(const DeclSpec& DS, ParsedType ObjectType) { - if (DS.getTypeSpecType() == DeclSpec::TST_error) + if (DS.getTypeSpecType() == DeclSpec::TST_error || !ObjectType) return ParsedType(); assert(DS.getTypeSpecType() == DeclSpec::TST_decltype && "only get destructor types from declspecs"); diff --git a/test/CXX/special/class.dtor/p10-0x.cpp b/test/CXX/special/class.dtor/p10-0x.cpp index 121624e7e2..7f0c07011e 100644 --- a/test/CXX/special/class.dtor/p10-0x.cpp +++ b/test/CXX/special/class.dtor/p10-0x.cpp @@ -22,4 +22,5 @@ void a(const A *x) { 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}} // this last one could be better, mentioning that the nested-name-specifier could be removed or a type name after the ~ x->::A::~decltype(*x)(); // expected-error{{expected a class name after '~' to name a destructor}} + y->~decltype(A())(); // expected-error{{use of undeclared identifier 'y'}} }