From 08608f6744b7bf179193f0891119d1f8ccc3568f Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Mon, 12 Dec 2011 04:13:55 +0000 Subject: [PATCH] Fix/test decltype dtor calls with invalid base expression. llvm-svn: 146354 --- clang/lib/Sema/SemaExprCXX.cpp | 2 +- clang/test/CXX/special/class.dtor/p10-0x.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index af297840c39c..59369d603d99 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/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/clang/test/CXX/special/class.dtor/p10-0x.cpp b/clang/test/CXX/special/class.dtor/p10-0x.cpp index 121624e7e2bd..7f0c07011ef6 100644 --- a/clang/test/CXX/special/class.dtor/p10-0x.cpp +++ b/clang/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'}} }