================
@@ -7484,6 +7484,17 @@ void Sema::ProcessDeclAttributeList(
}
}
+ // Do not permit 'constructor' or 'destructor' attributes on __device__ code.
+ if (getLangOpts().CUDAIsDevice && !getLangOpts().GPUAllowDeviceInit) {
+ if (D->hasAttr<ConstructorAttr>() && D->hasAttr<CUDADeviceAttr>()) {
----------------
Artem-B wrote:
`&& D->hasAttr<CUDADeviceAttr>()` could be hoisted into the top-level condition.
Nit: I'd probably go even further and make it a single linear chain of "and
this... and that..."
```
if (CUDAIsDevice
&& D->hasAttr<CUDADeviceAttr>()
&& (D->hasAttr<ConstructorAttr>() || D->hasAttr<DestructorAttr>())
&& !getLangOpts().GPUAllowDeviceInit) {
Diag(D->getLocation(), diag::err_cuda_ctor_dtor_attrs) <<
D->hasAttr<ConstructorAttr>() "constructors" : "destructors";
D->setInvalidDecl();
}
```
https://github.com/llvm/llvm-project/pull/126544
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits