Overloadable function candidate should not be viable if it uses extensions (Half or Double type) that are not enabled or supported.
Patch by Egor Churaev
Differential D51341
[HEADER] Overloadable function candidates for half/double types sidorovd on Aug 28 2018, 1:55 AM. Authored by
Details
Diff Detail Event Timeline
Comment Actions For now this patch is on hold since it adds no new functionality. Its future will be decided after @asavonic finished https://reviews.llvm.org/D51544 Comment Actions @Anastasia @yaxunl
#pragma OPENCL EXTENSION cl_khr_fp16 : enable half __attribute__((overloadable)) goo(half in1, half in2); // all ok #pragma OPENCL EXTENSION cl_khr_fp16 : disable #pragma OPENCL EXTENSION cl_khr_fp16 : begin half __attribute__((overloadable)) goo(half in1, half in2); // declaring function parameter of type 'half' is not allowed; did you forget * ? #pragma OPENCL EXTENSION cl_khr_fp16 : end
#pragma OPENCL EXTENSION all : begin #pragma OPENCL EXTENSION all : end #pragma OPENCL EXTENSION my_ext : begin ///some code #pragma OPENCL EXTENSION my_ext : end #pragma OPENCL EXTENSION my_ext : end // why? } so here my_ext has double ending. And in this way the test passes, but if I remove second ending (which is redundant from my perspective), I see following diagnostics: " OpenCL extension end directive mismatches begin directive - ignoring". Is it a bug or it's supposed to work that way? Comment Actions #pragma OPENCL EXTENSION ext_name : begin should not enable the extension. There are cases that you want to declare functions and types associated with an extension but do not want to enable the extension.
It seems to be a bug. |
I would imagine if extension isn't supported the candidate function with data type defined by extension shouldn't be available at all during compilation?
Also is there any good way to generalize this for all types and extensions including vendor ones that are added with the pragmas?
https://clang.llvm.org/docs/UsersManual.html#opencl-extensions