[PATCH] D94732: [CUDA] Normalize handling of defauled dtor.

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 19 17:50:11 PST 2021


rsmith added inline comments.


================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:15162-15170
+  bool SkipDtorChecks = VD->getType()->isArrayType();
+
+  // CUDA: Skip destructor checks for host-only variables during device-side
+  // compilation
+  SkipDtorChecks |=
+      (LangOpts.CUDAIsDevice && VD->hasGlobalStorage() &&
+       !(VD->hasAttr<CUDADeviceAttr>() || VD->hasAttr<CUDAConstantAttr>() ||
----------------
Is this safe? What happens if the destructor for the variable is a template, and instantiating that template results in a reference to a device function? Eg:

```
template<typename T> __device__ void f() {}
template<typename T> struct A {
  ~A() { f<<<>>>(); }
};
A a;
```


================
Comment at: clang/test/SemaCUDA/default-ctor.cu:28
   InHD inhd;
-  Out out; // expected-error{{no matching constructor for initialization of 'Out'}}
+  Out out;
   OutD outd;
----------------
I don't think we should accept this -- only functions that are defaulted on their first declaration should get special treatment. Instead of checking for `isDefaulted()` above, you should check for `!isUserProvided()` instead.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94732/new/

https://reviews.llvm.org/D94732



More information about the cfe-commits mailing list