Sorry for the delayed response.
If an OpenCL extension defines types and builtin functions. When this extension is disabled, we should diagnose the use of such types and builtin functions. If we did not do that already, that means our diagnostics need to be improved.
If we want to implement that purely in the compiler, we need to define the types and builtin functions of all extensions in Clang. As we know there are some limitations in the types that can be used in the builtin td file, so most likely these builtin functions definitions need to be added programmatically in Clang, which is a lengthy and error-prone process, and definitely not friendly to the library developers.
This justifies a better way to define the OpenCL extension and its associated types and builtin functions.
For certain types and builtin functions which require special semantics, implementation in Clang itself is unavoidable. However, for most extensions, probably we only need to diagnose the availability of the types and builtin functions associated with an extension, whereas the types and builtin functions themselves do not need special diagnostics. In such case defining them in Clang programmatically is unnecessary. We only need to have a way to tell Clang that these types and builtin functions are associated with an OpenCL extension.
Since these types and builtin functions are defined in header files, so naturally we can use pragma to do that.
I propose a modification of the previous proposal which allows us to associate types and function declarations with an OpenCL extension, e.g.
#pragma OpenCL EXTENSION new_extension : begin optional_available_opencl_version
Typedef global struct type1;
#pragma OpenCL EXTENSION new_extension : end
Basically the types and builtin functions defined between #pragma OpenCL EXTENSION name : begin and #pragma OpenCL EXTENSION name : end associates with the extension so that we can diagnose invalid uses of them.
I also added an optional argument for the pragma to indicate the earliest available OpenCL version of this extension so that we can diagnose incompatible OpenCL version for the extension.