OpenCL specification forbids use of several types as kernel
arguments. This patch improves existing diagnostic to look through
arrays.
Details
Diff Detail
- Repository
- rC Clang
Event Timeline
It seems however the restriction on pointer to pointer was removed (see s6.9.a last item) in CL2.0.
lib/Sema/SemaDecl.cpp | ||
---|---|---|
8187 | Do we need to assert PT here too? It doesn't seem to be modified in this loop... |
Right, and it seems that pointers in struct arguments should also be legal in CL2.0.
I'll submit another patch to remove this check for CL2.0.
lib/Sema/SemaDecl.cpp | ||
---|---|---|
8187 | We should check for a field instead. Thanks! |
This is admittedly a couple of years old by now, but wonder about that other intended patch - Clang still seems to consider pointers in struct arguments to be illegal in CL2.0 (and CL3.0) - please see https://godbolt.org/z/E87z66h1d
Yeah, the patch got lost somewhere, I'm sorry...
TBH, I don't know why pointers in structs or arrays were disallowed in the first place. Even OpenCL 1.2 does not say it explicitly, although there is a bit suspicious point in s6.9.p:
Arguments to kernel functions that are declared to be a struct or union do not allow OpenCL objects to be passed as elements of the struct or union
It does not say "pointers", just "OpenCL objects". Sounds more like events or images to me, not pointers.
Sure, trying to resurrect it in a comment above, and in D143849.
TBH, I don't know why pointers in structs or arrays were disallowed in the first place. Even OpenCL 1.2 does not say it explicitly, although there is a bit suspicious point in s6.9.p:
Arguments to kernel functions that are declared to be a struct or union do not allow OpenCL objects to be passed as elements of the struct or unionIt does not say "pointers", just "OpenCL objects". Sounds more like events or images to me, not pointers.
Yeah, there's room to improve clarity of the spec. Passing pointers indirectly requires them to point to same/share address space, as provided by SVM starting in OpenCL2.0.
lib/Sema/SemaDecl.cpp | ||
---|---|---|
8218 | Suggest to (rebase and) update this as follows, based on // union. This restriction was lifted in OpenCL v2.0 with the introduction // of SVM. if (S.getLangOpts().getOpenCLCompatibleVersion() > 120 && (ParamType == PtrKernelParam || ParamType == PtrPtrKernelParam)) continue; |
Do we need to assert PT here too? It doesn't seem to be modified in this loop...