================
@@ -7984,6 +7984,18 @@ void Sema::ProcessDeclAttributeList(
}
}
+ // CUDA/HIP: disallow explicit CUDA target attributes on deduction guides.
+ // Deduction guides are not callable functions and never participate in
+ // codegen; they are always treated as host+device for CUDA/HIP semantic
+ // checks, so explicit target attributes on them would be misleading noise.
+ if (getLangOpts().CUDA)
+ if (auto *Guide = dyn_cast<CXXDeductionGuideDecl>(D))
+ if (Guide->hasAttr<CUDAHostAttr>() || Guide->hasAttr<CUDADeviceAttr>() ||
+ Guide->hasAttr<CUDAGlobalAttr>()) {
+ Diag(Guide->getLocation(), diag::err_deduction_guide_target_attr);
+ Guide->setInvalidDecl();
+ }
----------------
yxsamliu wrote:
In non-CUDA mode, __attribute__((host)) on a deduction guide does not produce a
CUDAHostAttr; it's just an ignored/unknown attribute with a warning.
will revise as suggested
https://github.com/llvm/llvm-project/pull/168711
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits