[PATCH] D21912: [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:30:27 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL275231: [CUDA] Don't assume that destructors can't be overloaded. (authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D21912?vs=62444&id=63749#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21912

Files:
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/test/SemaCUDA/call-overloaded-destructor.cu

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();
+}
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<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());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21912.63749.patch
Type: text/x-patch
Size: 1450 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160712/a04ffd22/attachment.bin>


More information about the cfe-commits mailing list