Index: cfe/trunk/lib/Sema/SemaOverload.cpp =================================================================== --- cfe/trunk/lib/Sema/SemaOverload.cpp +++ cfe/trunk/lib/Sema/SemaOverload.cpp @@ -12407,8 +12407,7 @@ if (CXXDestructorDecl *DD = dyn_cast(TheCall->getMethodDecl())) { // a->A::f() doesn't go through the vtable, except in AppleKext mode. - bool CallCanBeVirtual = !cast(NakedMemExpr)->hasQualifier() || - getLangOpts().AppleKext; + bool CallCanBeVirtual = !MemExpr->hasQualifier() || getLangOpts().AppleKext; CheckVirtualDtorCall(DD, MemExpr->getLocStart(), /*IsDelete=*/false, CallCanBeVirtual, /*WarnOnNonAbstractTypes=*/true, MemExpr->getMemberLoc()); Index: cfe/trunk/test/SemaCUDA/call-overloaded-destructor.cu =================================================================== --- cfe/trunk/test/SemaCUDA/call-overloaded-destructor.cu +++ cfe/trunk/test/SemaCUDA/call-overloaded-destructor.cu @@ -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(); +}