From ebc93e176dad36fa8a28dd3a36c5b3dc7630d87d Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Thu, 12 May 2011 02:11:32 +0000 Subject: [PATCH] PR9899: handle pseudo-destructors correctly in noexcept() expressions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131220 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/Expr.cpp | 5 ++++- test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 7f15d86a19..a6d9bb8760 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -1750,11 +1750,14 @@ Expr::CanThrowResult Expr::CanThrow(ASTContext &C) const { case CallExprClass: case CXXOperatorCallExprClass: case CXXMemberCallExprClass: { + const CallExpr *CE = cast(this); CanThrowResult CT; if (isTypeDependent()) CT = CT_Dependent; + else if (isa(CE->getCallee()->IgnoreParens())) + CT = CT_Cannot; else - CT = CanCalleeThrow(C, cast(this)->getCalleeDecl()); + CT = CanCalleeThrow(C, CE->getCalleeDecl()); if (CT == CT_Can) return CT; return MergeCanThrow(CT, CanSubExprsThrow(C, this)); diff --git a/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp b/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp index 35a8b0f7d0..6d1e523b51 100644 --- a/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp +++ b/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp @@ -97,6 +97,8 @@ struct Bad2 { void operator delete(void*) throw(int); }; +typedef int X; + void implicits() { N(new int); P(new (0) int); @@ -113,6 +115,7 @@ void implicits() { N(static_cast(s)); P(static_cast(s)); N(Bad1()); + P(X().~X()); } struct V { -- 2.40.0