Hi,
I’m looking for advice on implementing diagnostics required by OpenCL v1.2 s6.12.14:
“Image memory objects that are being read by a kernel should be declared with the __read_only qualifier. write_image calls to image memory objects declared with the __read_only qualifier will generate a compilation error.”
My idea was to add image access qualifiers to the mangling and because built-in functions like write_image are mangled compiler will throw an error on passing an image with wrong access qualifier as it will not be able to find matching write_image built-in function.
Unfortunately it turned out that top level qualifiers are discarded by mangler.
Is any other better way to implement such diagnostics?
The main problem with it is that operations on OpenCL built-in types like images are defined as built-in function calls, which are typically defined by OpenCL run-time and not by Clang. Clang has no pre-defined knowledge about them.
I filed a ticket on clang #24937 to track similar problem, but it didn’t get any attention so far.
Thanks,
Alexey