Index: clang/lib/Sema/SemaLookup.cpp =================================================================== --- clang/lib/Sema/SemaLookup.cpp +++ clang/lib/Sema/SemaLookup.cpp @@ -815,9 +815,20 @@ // Ignore this builtin function if it carries an extension macro that is // not defined. This indicates that the extension is not supported by the // target, so the builtin function should not be available. - StringRef Ext = FunctionExtensionTable[OpenCLBuiltin.Extension]; - if (!Ext.empty() && !S.getPreprocessor().isMacroDefined(Ext)) - continue; + StringRef Extensions = FunctionExtensionTable[OpenCLBuiltin.Extension]; + if (!Extensions.empty()) { + SmallVector ExtVec; + Extensions.split(ExtVec, " "); + bool AllExtensionsDefined = true; + for (StringRef Ext : ExtVec) { + if (!S.getPreprocessor().isMacroDefined(Ext)) { + AllExtensionsDefined = false; + break; + } + } + if (!AllExtensionsDefined) + continue; + } SmallVector RetTypes; SmallVector, 5> ArgTypes; Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl =================================================================== --- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl +++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl @@ -17,6 +17,10 @@ #pragma OPENCL EXTENSION cl_khr_fp64 : enable #endif +#if __OPENCL_C_VERSION__ <= CL_VERSION_1_2 +#pragma OPENCL EXTENSION cl_khr_3d_image_writes : enable +#endif + // First, test that Clang gracefully handles missing types. #ifdef NO_HEADER void test_without_header() { @@ -169,13 +173,18 @@ } #endif // __OPENCL_C_VERSION__ >= CL_VERSION_2_0 -kernel void basic_image_writeonly(write_only image1d_buffer_t image_write_only_image1d_buffer) { +kernel void basic_image_writeonly(write_only image1d_buffer_t image_write_only_image1d_buffer, write_only image3d_t image3dwo) { half4 h4; float4 f4; int i; write_imagef(image_write_only_image1d_buffer, i, f4); write_imageh(image_write_only_image1d_buffer, i, h4); + +#if defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200 + int4 i4; + write_imagef(image3dwo, i4, i, f4); +#endif } kernel void basic_subgroup(global uint *out) {