Ha, I wondered if that would be the case. That parse error is also a bug. On 10 Oct 2013 12:33, "Benjamin Kramer" <[email protected]> wrote:
> > On 10.10.2013, at 20:31, Richard Smith <[email protected]> wrote: > > > What do we do in the corresponding case for constructors? It seems like > we should handle those two cases together. > > We generate a parse error way before we get to the address operator: > > test.c:3:15: error: expected '(' for function-style cast or type > construction > auto a = &A::A; > ~~~~^ > > - Ben > > > On 10 Oct 2013 02:49, "Benjamin Kramer" <[email protected]> > wrote: > > Author: d0k > > Date: Thu Oct 10 04:44:41 2013 > > New Revision: 192345 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=192345&view=rev > > Log: > > Sema: Taking the address of a dtor is illegal per C++ [class.dtor]p2. > > > > Emit a proper error instead of crashing in CodeGen. PR16892. > > > > Modified: > > cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > > cfe/trunk/lib/Sema/SemaExpr.cpp > > cfe/trunk/test/SemaCXX/destructor.cpp > > > > Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=192345&r1=192344&r2=192345&view=diff > > > ============================================================================== > > --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) > > +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Oct 10 > 04:44:41 2013 > > @@ -4483,6 +4483,8 @@ def ext_typecheck_addrof_temporary : Ext > > InGroup<DiagGroup<"address-of-temporary">>, DefaultError; > > def err_typecheck_addrof_temporary : Error< > > "taking the address of a temporary object of type %0">; > > +def err_typecheck_addrof_dtor : Error< > > + "taking the address of a destructor">; > > def err_typecheck_unary_expr : Error< > > "invalid argument type %0 to unary expression">; > > def err_typecheck_indirection_requires_pointer : Error< > > > > Modified: cfe/trunk/lib/Sema/SemaExpr.cpp > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=192345&r1=192344&r2=192345&view=diff > > > ============================================================================== > > --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) > > +++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Oct 10 04:44:41 2013 > > @@ -8709,6 +8709,10 @@ QualType Sema::CheckAddressOfOperand(Exp > > } > > } > > > > + // Taking the address of a dtor is illegal per C++ [class.dtor]p2. > > + if (isa<CXXDestructorDecl>(MD)) > > + Diag(OpLoc, diag::err_typecheck_addrof_dtor) << > op->getSourceRange(); > > + > > return Context.getMemberPointerType(op->getType(), > > Context.getTypeDeclType(MD->getParent()).getTypePtr()); > > } else if (lval != Expr::LV_Valid && lval != > Expr::LV_IncompleteVoidType) { > > > > Modified: cfe/trunk/test/SemaCXX/destructor.cpp > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/destructor.cpp?rev=192345&r1=192344&r2=192345&view=diff > > > ============================================================================== > > --- cfe/trunk/test/SemaCXX/destructor.cpp (original) > > +++ cfe/trunk/test/SemaCXX/destructor.cpp Thu Oct 10 04:44:41 2013 > > @@ -363,3 +363,7 @@ namespace PR7900 { > > (&b)->~A(); // expected-error{{destructor type 'PR7900::A' in > object destruction expression does not match the type 'PR7900::B' of the > object being destroyed}} > > } > > } > > + > > +namespace PR16892 { > > + auto p = &A::~A; // expected-error{{taking the address of a > destructor}} > > +} > > > > > > _______________________________________________ > > cfe-commits mailing list > > [email protected] > > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits > >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
