r275231 - [CUDA] Don't assume that destructors can't be overloaded.
Justin Lebar via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 12 16:23:02 PDT 2016
Author: jlebar
Date: Tue Jul 12 18:23:01 2016
New Revision: 275231
URL: http://llvm.org/viewvc/llvm-project?rev=275231&view=rev
Log:
[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
Added:
cfe/trunk/test/SemaCUDA/call-overloaded-destructor.cu
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=275231&r1=275230&r2=275231&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Jul 12 18:23:01 2016
@@ -12407,8 +12407,7 @@ Sema::BuildCallToMemberFunction(Scope *S
if (CXXDestructorDecl *DD =
dyn_cast<CXXDestructorDecl>(TheCall->getMethodDecl())) {
// a->A::f() doesn't go through the vtable, except in AppleKext mode.
- bool CallCanBeVirtual = !cast<MemberExpr>(NakedMemExpr)->hasQualifier() ||
- getLangOpts().AppleKext;
+ bool CallCanBeVirtual = !MemExpr->hasQualifier() || getLangOpts().AppleKext;
CheckVirtualDtorCall(DD, MemExpr->getLocStart(), /*IsDelete=*/false,
CallCanBeVirtual, /*WarnOnNonAbstractTypes=*/true,
MemExpr->getMemberLoc());
Added: cfe/trunk/test/SemaCUDA/call-overloaded-destructor.cu
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/call-overloaded-destructor.cu?rev=275231&view=auto
==============================================================================
--- cfe/trunk/test/SemaCUDA/call-overloaded-destructor.cu (added)
+++ cfe/trunk/test/SemaCUDA/call-overloaded-destructor.cu Tue Jul 12 18:23:01 2016
@@ -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();
+}
More information about the cfe-commits
mailing list