[CUDA] Don't assume that destructors can't be overloaded.

Summary:
You can overload a destructor in CUDA, and SemaOverload needs to be
tweaked not to crash when it sees an explicit call to an overloaded
destructor.

Reviewers: rsmith

Subscribers: cfe-commits, tra

Differential Revision: http://reviews.llvm.org/D21912

llvm-svn: 275231
This commit is contained in:
Justin Lebar 2016-07-12 23:23:01 +00:00
parent 51078b81ca
commit d35f706cc2
2 changed files with 18 additions and 2 deletions

View File

@ -12407,8 +12407,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
if (CXXDestructorDecl *DD = if (CXXDestructorDecl *DD =
dyn_cast<CXXDestructorDecl>(TheCall->getMethodDecl())) { dyn_cast<CXXDestructorDecl>(TheCall->getMethodDecl())) {
// a->A::f() doesn't go through the vtable, except in AppleKext mode. // a->A::f() doesn't go through the vtable, except in AppleKext mode.
bool CallCanBeVirtual = !cast<MemberExpr>(NakedMemExpr)->hasQualifier() || bool CallCanBeVirtual = !MemExpr->hasQualifier() || getLangOpts().AppleKext;
getLangOpts().AppleKext;
CheckVirtualDtorCall(DD, MemExpr->getLocStart(), /*IsDelete=*/false, CheckVirtualDtorCall(DD, MemExpr->getLocStart(), /*IsDelete=*/false,
CallCanBeVirtual, /*WarnOnNonAbstractTypes=*/true, CallCanBeVirtual, /*WarnOnNonAbstractTypes=*/true,
MemExpr->getMemberLoc()); MemExpr->getMemberLoc());

View File

@ -0,0 +1,17 @@
// expected-no-diagnostics
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fsyntax-only -fcuda-is-device -verify %s
#include "Inputs/cuda.h"
struct S {
__host__ ~S() {}
__device__ ~S() {}
};
__host__ __device__ void test() {
S s;
// This should not crash clang.
s.~S();
}