From: Richard Smith Date: Fri, 11 May 2012 22:20:10 +0000 (+0000) Subject: When diagnosing inaccessible temporary destructors in decltype expressions, use X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2f68ca09ca8b5944fcab14578a161511afde406f;p=clang When diagnosing inaccessible temporary destructors in decltype expressions, use the correct type and the correct source location in the diagnostic. Spotted by Johannes Schaub! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156654 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 7d987afe08..c0ba2d6cf8 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -4775,11 +4775,11 @@ ExprResult Sema::ActOnDecltypeExpression(Expr *E) { CXXDestructorDecl *Destructor = LookupDestructor(RD); Temp->setDestructor(Destructor); - MarkFunctionReferenced(E->getExprLoc(), Destructor); - CheckDestructorAccess(E->getExprLoc(), Destructor, + MarkFunctionReferenced(Bind->getExprLoc(), Destructor); + CheckDestructorAccess(Bind->getExprLoc(), Destructor, PDiag(diag::err_access_dtor_temp) - << E->getType()); - DiagnoseUseOfDecl(Destructor, E->getExprLoc()); + << Bind->getType()); + DiagnoseUseOfDecl(Destructor, Bind->getExprLoc()); // We need a cleanup, but we don't need to remember the temporary. ExprNeedsCleanups = true; diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp index 2bd5d234ce..093bc14d47 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp @@ -21,7 +21,7 @@ void r() { class PD { friend struct A; - ~PD(); // expected-note 4{{here}} + ~PD(); // expected-note 5{{here}} public: typedef int n; }; @@ -37,8 +37,14 @@ struct A { }; // Two errors here: one for the decltype, one for the variable. -decltype(PD(), PD()) pd1; // expected-error 2{{private destructor}} -decltype(DD(), DD()) dd1; // expected-error 2{{deleted function}} +decltype( + PD(), // expected-error {{private destructor}} + PD()) pd1; // expected-error {{private destructor}} +decltype(DD(), // expected-error {{deleted function}} + DD()) dd1; // expected-error {{deleted function}} +decltype( + PD(), // expected-error {{temporary of type 'PD' has private destructor}} + 0) pd2; decltype(((13, ((DD())))))::n dd_parens; // ok decltype(((((42)), PD())))::n pd_parens_comma; // ok