Open llvmbot opened 3 years ago
For OpenCL 1.0, the following extensions do no require pragma directive when they should according to the spec:
I looked at the values returned by clang::OpenCLOptions::isEnabled for each extension supported by Clang and found out that:
Furthermore, for the following extensions Clang does not require a #pragma directive when it should (i.e. BIFs/types are available/usable by default):
I'm not sure how cl_khr_srgb_image_writes should behave and therefore be tested.
Extended Description
The OpenCL specification requires implementation to disable all extensions by default. This implies that using any builtin functions from an extension should produce a compile-time error.
Clang doesn't respect this rules, at least not for all extensions as the following example shows:
unsigned int foo() { return get_sub_group_size(); }
This code compiles (while it should not) when using
opencl-c.h
and doesn't (as expected) when using -fdeclare-opencl-builtins.https://godbolt.org/z/WrMsMj
For reference, see the specification https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_Ext.html#compiler-directives-for-optional-extensions