================
@@ -5465,15 +5465,19 @@ static void handleGlobalAttr(Sema &S, Decl *D, const
ParsedAttr &AL) {
if (FD->isInlineSpecified() && !S.getLangOpts().CUDAIsDevice)
S.Diag(FD->getBeginLoc(), diag::warn_kern_is_inline) << FD;
- if (AL.getKind() == ParsedAttr::AT_DeviceKernel)
- D->addAttr(::new (S.Context) DeviceKernelAttr(S.Context, AL));
- else
+ // ***REVIEWER***: the existing code clearly expects either DeviceKernel or
+ // Global, and no others, but this does not appear to be made explicit?
+ if (AL.getKind() == ParsedAttr::AT_DeviceKernel) {
+ if (!D->hasAttr<DeviceKernelAttr>())
+ D->addAttr(::new (S.Context) DeviceKernelAttr(S.Context, AL));
+ } else if (!D->hasAttr<CUDAGlobalAttr>())
D->addAttr(::new (S.Context) CUDAGlobalAttr(S.Context, AL));
+
----------------
steffenlarsen wrote:
In accordance with the [style
guide](https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements):
```suggestion
} else if (!D->hasAttr<CUDAGlobalAttr>()) {
D->addAttr(::new (S.Context) CUDAGlobalAttr(S.Context, AL));
}
```
https://github.com/llvm/llvm-project/pull/218582
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits