https://github.com/wenju-he created 
https://github.com/llvm/llvm-project/pull/175120

Motivation is similar to 25cfdaa4e9dc. Their spec don't specify a required 
OpenCL version. Targets may expose them before OpenCL 1.2.
Set KHR extensions (depth images, mipmaps, subgroups, kernel clock, dot 
product, ext_float_atomics, extended_bit_ops) to availability 1.0.
Changes to opencl-c.h:
* Relax header and test guards to allow extension macros whenever any OpenCL C 
version is defined.
* Relax cl_khr_depth_images guard to allow cl_khr_depth_images, OpenCL C++, or 
OpenCL C 2.0+, since image2d_depth_t and image2d_array_depth_t types require 
that coverage.
* Guard image1d_t, image1d_array_t and image2d_array_t types with OpenCL C++ or 
OpenCL C 1.2+ to match with OpenCL C spec.

Relates to https://github.com/KhronosGroup/OpenCL-CTS/pull/2376.

>From 077905af42e28a05d142a01cf50d55f02c9c3f83 Mon Sep 17 00:00:00 2001
From: Wenju He <[email protected]>
Date: Fri, 9 Jan 2026 06:49:05 +0100
Subject: [PATCH] [OpenCL] Set KHR extensions minimum version to OpenCL 1.0

Motivation is similar to 25cfdaa4e9dc. Their spec don't specify a
required OpenCL version. Targets may expose them before OpenCL 1.2.

Set KHR extensions (depth images, mipmaps, subgroups, kernel clock,
dot product, ext_float_atomics, extended_bit_ops) to availability 1.0.

Changes to opencl-c.h:
* Relax header and test guards to allow extension macros whenever any
  OpenCL C version is defined.
* Relax cl_khr_depth_images guard to allow cl_khr_depth_images,
  OpenCL C++, or OpenCL C 2.0+, since image2d_depth_t and
  image2d_array_depth_t types require that coverage.
* Guard image1d_t, image1d_array_t and image2d_array_t types with
  OpenCL C++ or OpenCL C 1.2+ to match with OpenCL C spec.

Relates to https://github.com/KhronosGroup/OpenCL-CTS/pull/2376.
---
 .../include/clang/Basic/OpenCLExtensions.def  |  40 ++-
 clang/lib/Headers/opencl-c.h                  | 232 +++++++++++-------
 clang/test/Headers/opencl-c-header.cl         | 152 ++++++++----
 clang/test/Misc/amdgcn.languageOptsOpenCL.cl  |   4 +-
 clang/test/SemaOpenCL/extension-version.cl    |  40 +--
 .../SemaOpenCL/fdeclare-opencl-builtins.cl    |   8 +-
 6 files changed, 293 insertions(+), 183 deletions(-)

diff --git a/clang/include/clang/Basic/OpenCLExtensions.def 
b/clang/include/clang/Basic/OpenCLExtensions.def
index 3abc0279de791..d6c0b585d1809 100644
--- a/clang/include/clang/Basic/OpenCLExtensions.def
+++ b/clang/include/clang/Basic/OpenCLExtensions.def
@@ -68,33 +68,31 @@ OPENCL_OPTIONALCOREFEATURE(cl_khr_fp64, true, 100, 
OCL_C_12P)
 OPENCL_EXTENSION(cl_khr_fp16, true, 100)
 OPENCL_EXTENSION(cl_khr_int64_base_atomics, true, 100)
 OPENCL_EXTENSION(cl_khr_int64_extended_atomics, true, 100)
+OPENCL_EXTENSION(cl_khr_depth_images, true, 100)
+OPENCL_EXTENSION(cl_khr_extended_bit_ops, false, 100)
+OPENCL_EXTENSION(cl_ext_float_atomics, false, 100)
 OPENCL_EXTENSION(cl_khr_gl_msaa_sharing, true, 100)
+OPENCL_EXTENSION(cl_khr_integer_dot_product, false, 100)
+OPENCL_EXTENSION(cl_khr_kernel_clock, false, 100)
+OPENCL_EXTENSION(cl_khr_mipmap_image, true, 100)
+OPENCL_EXTENSION(cl_khr_mipmap_image_writes, true, 100)
+OPENCL_EXTENSION(cl_khr_srgb_image_writes, true, 100)
+OPENCL_EXTENSION(cl_khr_subgroup_ballot, false, 100)
+OPENCL_EXTENSION(cl_khr_subgroup_clustered_reduce, false, 100)
+OPENCL_EXTENSION(cl_khr_subgroup_extended_types, false, 100)
+OPENCL_EXTENSION(cl_khr_subgroup_named_barrier, false, 100)
+OPENCL_EXTENSION(cl_khr_subgroup_non_uniform_arithmetic, false, 100)
+OPENCL_EXTENSION(cl_khr_subgroup_non_uniform_vote, false, 100)
+OPENCL_EXTENSION(cl_khr_subgroup_rotate, false, 100)
+OPENCL_EXTENSION(cl_khr_subgroup_shuffle_relative, false, 100)
+OPENCL_EXTENSION(cl_khr_subgroup_shuffle, false, 100)
+OPENCL_EXTENSION(cl_khr_subgroups, true, 100)
 OPENCL_GENERIC_EXTENSION(cl_khr_3d_image_writes, true, 100, OCL_C_20, OCL_C_30)
 
 // EMBEDDED_PROFILE
-OPENCL_EXTENSION(cles_khr_int64, true, 110)
-
-// OpenCL 1.2.
-OPENCL_EXTENSION(cl_khr_depth_images, true, 120)
+OPENCL_EXTENSION(cles_khr_int64, true, 100)
 
 // OpenCL 2.0.
-OPENCL_EXTENSION(cl_ext_float_atomics, false, 200)
-OPENCL_EXTENSION(cl_khr_extended_bit_ops, false, 200)
-OPENCL_EXTENSION(cl_khr_integer_dot_product, false, 200)
-OPENCL_EXTENSION(cl_khr_kernel_clock, false, 200)
-OPENCL_EXTENSION(cl_khr_mipmap_image, true, 200)
-OPENCL_EXTENSION(cl_khr_mipmap_image_writes, true, 200)
-OPENCL_EXTENSION(cl_khr_srgb_image_writes, true, 200)
-OPENCL_EXTENSION(cl_khr_subgroup_ballot, false, 200)
-OPENCL_EXTENSION(cl_khr_subgroup_clustered_reduce, false, 200)
-OPENCL_EXTENSION(cl_khr_subgroup_extended_types, false, 200)
-OPENCL_EXTENSION(cl_khr_subgroup_named_barrier, false, 200)
-OPENCL_EXTENSION(cl_khr_subgroup_non_uniform_arithmetic, false, 200)
-OPENCL_EXTENSION(cl_khr_subgroup_non_uniform_vote, false, 200)
-OPENCL_EXTENSION(cl_khr_subgroup_rotate, false, 200)
-OPENCL_EXTENSION(cl_khr_subgroup_shuffle_relative, false, 200)
-OPENCL_EXTENSION(cl_khr_subgroup_shuffle, false, 200)
-OPENCL_EXTENSION(cl_khr_subgroups, true, 200)
 OPENCL_GENERIC_EXTENSION(__opencl_c_atomic_order_acq_rel, false, 200, 
OCL_C_20, OCL_C_30)
 OPENCL_GENERIC_EXTENSION(__opencl_c_atomic_order_seq_cst, false, 200, 
OCL_C_20, OCL_C_30)
 OPENCL_GENERIC_EXTENSION(__opencl_c_atomic_scope_all_devices, false, 200, 
OCL_C_20, OCL_C_30)
diff --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index 72a1333ee05dc..08645f4745601 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -17,6 +17,13 @@
 #endif //cl_khr_depth_images
 #endif //defined(__opencl_c_images)
 
+#if defined(cl_khr_depth_images) || defined(__OPENCL_CPP_VERSION__) ||         
\
+    (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+// Internal feature macro to provide depth image builtins.
+#define __opencl_depth_image_builtins 1
+#endif // defined(cl_khr_depth_images) || defined(__OPENCL_CPP_VERSION__) ||
+       // (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
 #ifdef cl_khr_3d_image_writes
 #pragma OPENCL EXTENSION cl_khr_3d_image_writes : enable
@@ -15199,8 +15206,8 @@ float4 __ovld __purefn read_imagef(read_only 
image2d_array_t, sampler_t, float4)
 int4 __ovld __purefn read_imagei(read_only image2d_array_t, sampler_t, int4);
 int4 __ovld __purefn read_imagei(read_only image2d_array_t, sampler_t, float4);
 uint4 __ovld __purefn read_imageui(read_only image2d_array_t, sampler_t, int4);
-uint4 __ovld __purefn read_imageui(read_only image2d_array_t, sampler_t, 
float4);
-#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_1_2)
+uint4 __ovld __purefn read_imageui(read_only image2d_array_t, sampler_t,
+                                   float4);
 
 float4 __ovld __purefn read_imagef(read_only image1d_t, sampler_t, int);
 float4 __ovld __purefn read_imagef(read_only image1d_t, sampler_t, float);
@@ -15210,7 +15217,6 @@ int4 __ovld __purefn read_imagei(read_only image1d_t, 
sampler_t, float);
 uint4 __ovld __purefn read_imageui(read_only image1d_t, sampler_t, int);
 uint4 __ovld __purefn read_imageui(read_only image1d_t, sampler_t, float);
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
 float4 __ovld __purefn read_imagef(read_only image1d_array_t, sampler_t, int2);
 float4 __ovld __purefn read_imagef(read_only image1d_array_t, sampler_t, 
float2);
 
@@ -15220,13 +15226,13 @@ uint4 __ovld __purefn read_imageui(read_only 
image1d_array_t, sampler_t, int2);
 uint4 __ovld __purefn read_imageui(read_only image1d_array_t, sampler_t, 
float2);
 #endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_1_2)
 
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 float __ovld __purefn read_imagef(read_only image2d_depth_t, sampler_t, 
float2);
 float __ovld __purefn read_imagef(read_only image2d_depth_t, sampler_t, int2);
 
 float __ovld __purefn read_imagef(read_only image2d_array_depth_t, sampler_t, 
float4);
 float __ovld __purefn read_imagef(read_only image2d_array_depth_t, sampler_t, 
int4);
-#endif //cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 
 #if defined(cl_khr_gl_msaa_sharing)
 float4 __ovld __purefn read_imagef(read_only image2d_msaa_t, int2, int);
@@ -15243,9 +15249,10 @@ float __ovld __purefn read_imagef(read_only 
image2d_array_msaa_depth_t, int4, in
 #endif //cl_khr_gl_msaa_sharing
 
 // OpenCL Extension v2.0 s9.18 - Mipmaps
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__)
 #ifdef cl_khr_mipmap_image
 
+#if __OPENCL_C_VERSION__ >= CL_VERSION_1_2
 float4 __ovld __purefn read_imagef(read_only image1d_t, sampler_t, float, 
float);
 int4 __ovld __purefn read_imagei(read_only image1d_t, sampler_t, float, float);
 uint4 __ovld __purefn read_imageui(read_only image1d_t, sampler_t, float, 
float);
@@ -15253,27 +15260,31 @@ uint4 __ovld __purefn read_imageui(read_only 
image1d_t, sampler_t, float, float)
 float4 __ovld __purefn read_imagef(read_only image1d_array_t, sampler_t, 
float2, float);
 int4 __ovld __purefn read_imagei(read_only image1d_array_t, sampler_t, float2, 
float);
 uint4 __ovld __purefn read_imageui(read_only image1d_array_t, sampler_t, 
float2, float);
+#endif // __OPENCL_C_VERSION__ >= CL_VERSION_1_2
 
 float4 __ovld __purefn read_imagef(read_only image2d_t, sampler_t, float2, 
float);
 int4 __ovld __purefn read_imagei(read_only image2d_t, sampler_t, float2, 
float);
 uint4 __ovld __purefn read_imageui(read_only image2d_t, sampler_t, float2, 
float);
 
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 float __ovld __purefn read_imagef(read_only image2d_depth_t, sampler_t, 
float2, float);
-#endif // cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 
+#if __OPENCL_C_VERSION__ >= CL_VERSION_1_2
 float4 __ovld __purefn read_imagef(read_only image2d_array_t, sampler_t, 
float4, float);
 int4 __ovld __purefn read_imagei(read_only image2d_array_t, sampler_t, float4, 
float);
 uint4 __ovld __purefn read_imageui(read_only image2d_array_t, sampler_t, 
float4, float);
+#endif // __OPENCL_C_VERSION__ >= CL_VERSION_1_2
 
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 float __ovld __purefn read_imagef(read_only image2d_array_depth_t, sampler_t, 
float4, float);
-#endif // cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 
 float4 __ovld __purefn read_imagef(read_only image3d_t, sampler_t, float4, 
float);
 int4 __ovld __purefn read_imagei(read_only image3d_t, sampler_t, float4, 
float);
 uint4 __ovld __purefn read_imageui(read_only image3d_t, sampler_t, float4, 
float);
 
+#if __OPENCL_C_VERSION__ >= CL_VERSION_1_2
 float4 __ovld __purefn read_imagef(read_only image1d_t, sampler_t, float, 
float, float);
 int4 __ovld __purefn read_imagei(read_only image1d_t, sampler_t, float, float, 
float);
 uint4 __ovld __purefn read_imageui(read_only image1d_t, sampler_t, float, 
float, float);
@@ -15281,31 +15292,34 @@ uint4 __ovld __purefn read_imageui(read_only 
image1d_t, sampler_t, float, float,
 float4 __ovld __purefn read_imagef(read_only image1d_array_t, sampler_t, 
float2, float, float);
 int4 __ovld __purefn read_imagei(read_only image1d_array_t, sampler_t, float2, 
float, float);
 uint4 __ovld __purefn read_imageui(read_only image1d_array_t, sampler_t, 
float2, float, float);
+#endif // __OPENCL_C_VERSION__ >= CL_VERSION_1_2
 
 float4 __ovld __purefn read_imagef(read_only image2d_t, sampler_t, float2, 
float2, float2);
 int4 __ovld __purefn read_imagei(read_only image2d_t, sampler_t, float2, 
float2, float2);
 uint4 __ovld __purefn read_imageui(read_only image2d_t, sampler_t, float2, 
float2, float2);
 
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 float __ovld __purefn read_imagef(read_only image2d_depth_t, sampler_t, 
float2, float2, float2);
-#endif // cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 
+#if __OPENCL_C_VERSION__ >= CL_VERSION_1_2
 float4 __ovld __purefn read_imagef(read_only image2d_array_t, sampler_t, 
float4, float2, float2);
 int4 __ovld __purefn read_imagei(read_only image2d_array_t, sampler_t, float4, 
float2, float2);
 uint4 __ovld __purefn read_imageui(read_only image2d_array_t, sampler_t, 
float4, float2, float2);
+#endif // __OPENCL_C_VERSION__ >= CL_VERSION_1_2
 
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 float __ovld __purefn read_imagef(read_only image2d_array_depth_t, sampler_t, 
float4, float2, float2);
-#endif // cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 
 float4 __ovld __purefn read_imagef(read_only image3d_t, sampler_t, float4, 
float4, float4);
 int4 __ovld __purefn read_imagei(read_only image3d_t, sampler_t, float4, 
float4, float4);
 uint4 __ovld __purefn read_imageui(read_only image3d_t, sampler_t, float4, 
float4, float4);
 
 #endif //cl_khr_mipmap_image
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
+#endif // defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__)
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
+#if defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__)
 
 /**
 * Sampler-less Image Access
@@ -15331,36 +15345,39 @@ float4 __ovld __purefn read_imagef(read_only 
image2d_array_t, int4);
 int4 __ovld __purefn read_imagei(read_only image2d_array_t, int4);
 uint4 __ovld __purefn read_imageui(read_only image2d_array_t, int4);
 
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 float __ovld __purefn read_imagef(read_only image2d_depth_t, int2);
 float __ovld __purefn read_imagef(read_only image2d_array_depth_t, int4);
-#endif //cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 
 float4 __ovld __purefn read_imagef(read_only image3d_t, int4);
 int4 __ovld __purefn read_imagei(read_only image3d_t, int4);
 uint4 __ovld __purefn read_imageui(read_only image3d_t, int4);
 
-#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_1_2)
+#endif // defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__)
 
 // Image read functions returning half4 type
 #ifdef cl_khr_fp16
-half4 __ovld __purefn read_imageh(read_only image1d_t, sampler_t, int);
-half4 __ovld __purefn read_imageh(read_only image1d_t, sampler_t, float);
 half4 __ovld __purefn read_imageh(read_only image2d_t, sampler_t, int2);
 half4 __ovld __purefn read_imageh(read_only image2d_t, sampler_t, float2);
 half4 __ovld __purefn read_imageh(read_only image3d_t, sampler_t, int4);
 half4 __ovld __purefn read_imageh(read_only image3d_t, sampler_t, float4);
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
+half4 __ovld __purefn read_imageh(read_only image1d_t, sampler_t, int);
+half4 __ovld __purefn read_imageh(read_only image1d_t, sampler_t, float);
 half4 __ovld __purefn read_imageh(read_only image1d_array_t, sampler_t, int2);
 half4 __ovld __purefn read_imageh(read_only image1d_array_t, sampler_t, 
float2);
 half4 __ovld __purefn read_imageh(read_only image2d_array_t, sampler_t, int4);
 half4 __ovld __purefn read_imageh(read_only image2d_array_t, sampler_t, 
float4);
+#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >=
+       // CL_VERSION_1_2)
 /**
  * Sampler-less Image Access
  */
-half4 __ovld __purefn read_imageh(read_only image1d_t, int);
 half4 __ovld __purefn read_imageh(read_only image2d_t, int2);
 half4 __ovld __purefn read_imageh(read_only image3d_t, int4);
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
+half4 __ovld __purefn read_imageh(read_only image1d_t, int);
 half4 __ovld __purefn read_imageh(read_only image1d_array_t, int2);
 half4 __ovld __purefn read_imageh(read_only image2d_array_t, int4);
 half4 __ovld __purefn read_imageh(read_only image1d_buffer_t, int);
@@ -15395,10 +15412,10 @@ int4 __ovld __purefn read_imagei(read_write 
image3d_t, int4);
 uint4 __ovld __purefn read_imageui(read_write image3d_t, int4);
 #endif // cl_khr_3d_image_writes
 
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 float __ovld __purefn read_imagef(read_write image2d_depth_t, int2);
 float __ovld __purefn read_imagef(read_write image2d_array_depth_t, int4);
-#endif //cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 
 #if cl_khr_gl_msaa_sharing
 float4 __ovld __purefn read_imagef(read_write image2d_msaa_t, int2, int);
@@ -15414,6 +15431,7 @@ float __ovld __purefn read_imagef(read_write 
image2d_array_msaa_depth_t, int4, i
 #endif //cl_khr_gl_msaa_sharing
 
 #ifdef cl_khr_mipmap_image
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
 float4 __ovld __purefn read_imagef(read_write image1d_t, sampler_t, float, 
float);
 int4 __ovld __purefn read_imagei(read_write image1d_t, sampler_t, float, 
float);
 uint4 __ovld __purefn read_imageui(read_write image1d_t, sampler_t, float, 
float);
@@ -15421,18 +15439,27 @@ uint4 __ovld __purefn read_imageui(read_write 
image1d_t, sampler_t, float, float
 float4 __ovld __purefn read_imagef(read_write image1d_array_t, sampler_t, 
float2, float);
 int4 __ovld __purefn read_imagei(read_write image1d_array_t, sampler_t, 
float2, float);
 uint4 __ovld __purefn read_imageui(read_write image1d_array_t, sampler_t, 
float2, float);
+#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >=
+       // CL_VERSION_1_2)
 
 float4 __ovld __purefn read_imagef(read_write image2d_t, sampler_t, float2, 
float);
 int4 __ovld __purefn read_imagei(read_write image2d_t, sampler_t, float2, 
float);
 uint4 __ovld __purefn read_imageui(read_write image2d_t, sampler_t, float2, 
float);
 
+#if defined(__opencl_depth_image_builtins)
 float __ovld __purefn read_imagef(read_write image2d_depth_t, sampler_t, 
float2, float);
+#endif // defined(__opencl_depth_image_builtins)
 
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
 float4 __ovld __purefn read_imagef(read_write image2d_array_t, sampler_t, 
float4, float);
 int4 __ovld __purefn read_imagei(read_write image2d_array_t, sampler_t, 
float4, float);
 uint4 __ovld __purefn read_imageui(read_write image2d_array_t, sampler_t, 
float4, float);
+#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >=
+       // CL_VERSION_1_2)
 
+#if defined(__opencl_depth_image_builtins)
 float __ovld __purefn read_imagef(read_write image2d_array_depth_t, sampler_t, 
float4, float);
+#endif // defined(__opencl_depth_image_builtins)
 
 #ifdef cl_khr_3d_image_writes
 float4 __ovld __purefn read_imagef(read_write image3d_t, sampler_t, float4, 
float);
@@ -15440,6 +15467,7 @@ int4 __ovld __purefn read_imagei(read_write image3d_t, 
sampler_t, float4, float)
 uint4 __ovld __purefn read_imageui(read_write image3d_t, sampler_t, float4, 
float);
 #endif // cl_khr_3d_image_writes
 
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
 float4 __ovld __purefn read_imagef(read_write image1d_t, sampler_t, float, 
float, float);
 int4 __ovld __purefn read_imagei(read_write image1d_t, sampler_t, float, 
float, float);
 uint4 __ovld __purefn read_imageui(read_write image1d_t, sampler_t, float, 
float, float);
@@ -15447,18 +15475,27 @@ uint4 __ovld __purefn read_imageui(read_write 
image1d_t, sampler_t, float, float
 float4 __ovld __purefn read_imagef(read_write image1d_array_t, sampler_t, 
float2, float, float);
 int4 __ovld __purefn read_imagei(read_write image1d_array_t, sampler_t, 
float2, float, float);
 uint4 __ovld __purefn read_imageui(read_write image1d_array_t, sampler_t, 
float2, float, float);
+#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >=
+       // CL_VERSION_1_2)
 
 float4 __ovld __purefn read_imagef(read_write image2d_t, sampler_t, float2, 
float2, float2);
 int4 __ovld __purefn read_imagei(read_write image2d_t, sampler_t, float2, 
float2, float2);
 uint4 __ovld __purefn read_imageui(read_write image2d_t, sampler_t, float2, 
float2, float2);
 
+#if defined(__opencl_depth_image_builtins)
 float __ovld __purefn read_imagef(read_write image2d_depth_t, sampler_t, 
float2, float2, float2);
+#endif // defined(__opencl_depth_image_builtins)
 
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
 float4 __ovld __purefn read_imagef(read_write image2d_array_t, sampler_t, 
float4, float2, float2);
 int4 __ovld __purefn read_imagei(read_write image2d_array_t, sampler_t, 
float4, float2, float2);
 uint4 __ovld __purefn read_imageui(read_write image2d_array_t, sampler_t, 
float4, float2, float2);
+#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >=
+       // CL_VERSION_1_2)
 
+#if defined(__opencl_depth_image_builtins)
 float __ovld __purefn read_imagef(read_write image2d_array_depth_t, sampler_t, 
float4, float2, float2);
+#endif // defined(__opencl_depth_image_builtins)
 
 #ifdef cl_khr_3d_image_writes
 float4 __ovld __purefn read_imagef(read_write image3d_t, sampler_t, float4, 
float4, float4);
@@ -15574,14 +15611,14 @@ void __ovld write_imagei(write_only image3d_t, int4, 
int4);
 void __ovld write_imageui(write_only image3d_t, int4, uint4);
 #endif
 
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 void __ovld write_imagef(write_only image2d_depth_t, int2, float);
 void __ovld write_imagef(write_only image2d_array_depth_t, int4, float);
-#endif //cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 
 // OpenCL Extension v2.0 s9.18 - Mipmaps
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 #if defined(cl_khr_mipmap_image_writes)
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
 void __ovld write_imagef(write_only image1d_t, int, int, float4);
 void __ovld write_imagei(write_only image1d_t, int, int, int4);
 void __ovld write_imageui(write_only image1d_t, int, int, uint4);
@@ -15590,16 +15627,20 @@ void __ovld write_imagef(write_only image1d_array_t, 
int2, int, float4);
 void __ovld write_imagei(write_only image1d_array_t, int2, int, int4);
 void __ovld write_imageui(write_only image1d_array_t, int2, int, uint4);
 
-void __ovld write_imagef(write_only image2d_t, int2, int, float4);
-void __ovld write_imagei(write_only image2d_t, int2, int, int4);
-void __ovld write_imageui(write_only image2d_t, int2, int, uint4);
-
 void __ovld write_imagef(write_only image2d_array_t, int4, int, float4);
 void __ovld write_imagei(write_only image2d_array_t, int4, int, int4);
 void __ovld write_imageui(write_only image2d_array_t, int4, int, uint4);
+#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >=
+       // CL_VERSION_1_2)
+
+void __ovld write_imagef(write_only image2d_t, int2, int, float4);
+void __ovld write_imagei(write_only image2d_t, int2, int, int4);
+void __ovld write_imageui(write_only image2d_t, int2, int, uint4);
 
+#if defined(__opencl_depth_image_builtins)
 void __ovld write_imagef(write_only image2d_depth_t, int2, int, float);
 void __ovld write_imagef(write_only image2d_array_depth_t, int4, int, float);
+#endif // defined(__opencl_depth_image_builtins)
 
 #ifdef cl_khr_3d_image_writes
 void __ovld write_imagef(write_only image3d_t, int4, int, float4);
@@ -15607,8 +15648,7 @@ void __ovld write_imagei(write_only image3d_t, int4, 
int, int4);
 void __ovld write_imageui(write_only image3d_t, int4, int, uint4);
 #endif //cl_khr_3d_image_writes
 
-#endif //defined(cl_khr_mipmap_image_writes)
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
+#endif // defined(cl_khr_mipmap_image_writes)
 
 // Image write functions for half4 type
 #ifdef cl_khr_fp16
@@ -15650,12 +15690,13 @@ void __ovld write_imagei(read_write image3d_t, int4, 
int4);
 void __ovld write_imageui(read_write image3d_t, int4, uint4);
 #endif
 
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 void __ovld write_imagef(read_write image2d_depth_t, int2, float);
 void __ovld write_imagef(read_write image2d_array_depth_t, int4, float);
-#endif //cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 
 #if defined(cl_khr_mipmap_image_writes)
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
 void __ovld write_imagef(read_write image1d_t, int, int, float4);
 void __ovld write_imagei(read_write image1d_t, int, int, int4);
 void __ovld write_imageui(read_write image1d_t, int, int, uint4);
@@ -15664,16 +15705,20 @@ void __ovld write_imagef(read_write image1d_array_t, 
int2, int, float4);
 void __ovld write_imagei(read_write image1d_array_t, int2, int, int4);
 void __ovld write_imageui(read_write image1d_array_t, int2, int, uint4);
 
-void __ovld write_imagef(read_write image2d_t, int2, int, float4);
-void __ovld write_imagei(read_write image2d_t, int2, int, int4);
-void __ovld write_imageui(read_write image2d_t, int2, int, uint4);
-
 void __ovld write_imagef(read_write image2d_array_t, int4, int, float4);
 void __ovld write_imagei(read_write image2d_array_t, int4, int, int4);
 void __ovld write_imageui(read_write image2d_array_t, int4, int, uint4);
+#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >=
+       // CL_VERSION_1_2)
+
+void __ovld write_imagef(read_write image2d_t, int2, int, float4);
+void __ovld write_imagei(read_write image2d_t, int2, int, int4);
+void __ovld write_imageui(read_write image2d_t, int2, int, uint4);
 
+#if defined(__opencl_depth_image_builtins)
 void __ovld write_imagef(read_write image2d_depth_t, int2, int, float);
 void __ovld write_imagef(read_write image2d_array_depth_t, int4, int, float);
+#endif // defined(__opencl_depth_image_builtins)
 
 #ifdef cl_khr_3d_image_writes
 void __ovld write_imagef(read_write image3d_t, int4, int, float4);
@@ -15710,10 +15755,10 @@ int __ovld __cnfn get_image_width(read_only 
image2d_t);
 int __ovld __cnfn get_image_width(read_only image3d_t);
 int __ovld __cnfn get_image_width(read_only image1d_array_t);
 int __ovld __cnfn get_image_width(read_only image2d_array_t);
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 int __ovld __cnfn get_image_width(read_only image2d_depth_t);
 int __ovld __cnfn get_image_width(read_only image2d_array_depth_t);
-#endif //cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 #if defined(cl_khr_gl_msaa_sharing)
 int __ovld __cnfn get_image_width(read_only image2d_msaa_t);
 int __ovld __cnfn get_image_width(read_only image2d_msaa_depth_t);
@@ -15729,10 +15774,10 @@ int __ovld __cnfn get_image_width(write_only 
image3d_t);
 #endif
 int __ovld __cnfn get_image_width(write_only image1d_array_t);
 int __ovld __cnfn get_image_width(write_only image2d_array_t);
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 int __ovld __cnfn get_image_width(write_only image2d_depth_t);
 int __ovld __cnfn get_image_width(write_only image2d_array_depth_t);
-#endif //cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 #if defined(cl_khr_gl_msaa_sharing)
 int __ovld __cnfn get_image_width(write_only image2d_msaa_t);
 int __ovld __cnfn get_image_width(write_only image2d_msaa_depth_t);
@@ -15749,10 +15794,10 @@ int __ovld __cnfn get_image_width(read_write 
image3d_t);
 #endif // cl_khr_3d_image_writes
 int __ovld __cnfn get_image_width(read_write image1d_array_t);
 int __ovld __cnfn get_image_width(read_write image2d_array_t);
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 int __ovld __cnfn get_image_width(read_write image2d_depth_t);
 int __ovld __cnfn get_image_width(read_write image2d_array_depth_t);
-#endif //cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 #if defined(cl_khr_gl_msaa_sharing)
 int __ovld __cnfn get_image_width(read_write image2d_msaa_t);
 int __ovld __cnfn get_image_width(read_write image2d_msaa_depth_t);
@@ -15767,10 +15812,10 @@ int __ovld __cnfn get_image_width(read_write 
image2d_array_msaa_depth_t);
 int __ovld __cnfn get_image_height(read_only image2d_t);
 int __ovld __cnfn get_image_height(read_only image3d_t);
 int __ovld __cnfn get_image_height(read_only image2d_array_t);
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 int __ovld __cnfn get_image_height(read_only image2d_depth_t);
 int __ovld __cnfn get_image_height(read_only image2d_array_depth_t);
-#endif //cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 #if defined(cl_khr_gl_msaa_sharing)
 int __ovld __cnfn get_image_height(read_only image2d_msaa_t);
 int __ovld __cnfn get_image_height(read_only image2d_msaa_depth_t);
@@ -15783,10 +15828,10 @@ int __ovld __cnfn get_image_height(write_only 
image2d_t);
 int __ovld __cnfn get_image_height(write_only image3d_t);
 #endif
 int __ovld __cnfn get_image_height(write_only image2d_array_t);
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 int __ovld __cnfn get_image_height(write_only image2d_depth_t);
 int __ovld __cnfn get_image_height(write_only image2d_array_depth_t);
-#endif //cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 #if defined(cl_khr_gl_msaa_sharing)
 int __ovld __cnfn get_image_height(write_only image2d_msaa_t);
 int __ovld __cnfn get_image_height(write_only image2d_msaa_depth_t);
@@ -15800,10 +15845,10 @@ int __ovld __cnfn get_image_height(read_write 
image2d_t);
 int __ovld __cnfn get_image_height(read_write image3d_t);
 #endif // cl_khr_3d_image_writes
 int __ovld __cnfn get_image_height(read_write image2d_array_t);
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 int __ovld __cnfn get_image_height(read_write image2d_depth_t);
 int __ovld __cnfn get_image_height(read_write image2d_array_depth_t);
-#endif //cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 #if defined(cl_khr_gl_msaa_sharing)
 int __ovld __cnfn get_image_height(read_write image2d_msaa_t);
 int __ovld __cnfn get_image_height(read_write image2d_msaa_depth_t);
@@ -15825,18 +15870,22 @@ int __ovld __cnfn get_image_depth(read_write 
image3d_t);
 #endif //defined(__opencl_c_read_write_images)
 #endif // cl_khr_3d_image_writes
 
-// OpenCL Extension v2.0 s9.18 - Mipmaps
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+// OpenCL Extension - Mipmaps
+#if defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__)
 #ifdef cl_khr_mipmap_image
 /**
  * Return the image miplevels.
  */
 
+#if __OPENCL_C_VERSION__ >= CL_VERSION_1_2
 int __ovld get_image_num_mip_levels(read_only image1d_t);
+#endif // __OPENCL_C_VERSION__ >= CL_VERSION_1_2
 int __ovld get_image_num_mip_levels(read_only image2d_t);
 int __ovld get_image_num_mip_levels(read_only image3d_t);
 
+#if __OPENCL_C_VERSION__ >= CL_VERSION_1_2
 int __ovld get_image_num_mip_levels(write_only image1d_t);
+#endif // __OPENCL_C_VERSION__ >= CL_VERSION_1_2
 int __ovld get_image_num_mip_levels(write_only image2d_t);
 #ifdef cl_khr_3d_image_writes
 int __ovld get_image_num_mip_levels(write_only image3d_t);
@@ -15850,31 +15899,37 @@ int __ovld get_image_num_mip_levels(read_write 
image3d_t);
 #endif // cl_khr_3d_image_writes
 #endif //defined(__opencl_c_read_write_images)
 
+#if __OPENCL_C_VERSION__ >= CL_VERSION_1_2
 int __ovld get_image_num_mip_levels(read_only image1d_array_t);
 int __ovld get_image_num_mip_levels(read_only image2d_array_t);
-#ifdef cl_khr_depth_images
+#endif // __OPENCL_C_VERSION__ >= CL_VERSION_1_2
+#if defined(__opencl_depth_image_builtins)
 int __ovld get_image_num_mip_levels(read_only image2d_array_depth_t);
 int __ovld get_image_num_mip_levels(read_only image2d_depth_t);
-#endif // cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 
+#if __OPENCL_C_VERSION__ >= CL_VERSION_1_2
 int __ovld get_image_num_mip_levels(write_only image1d_array_t);
 int __ovld get_image_num_mip_levels(write_only image2d_array_t);
-#ifdef cl_khr_depth_images
+#endif // __OPENCL_C_VERSION__ >= CL_VERSION_1_2
+#if defined(__opencl_depth_image_builtins)
 int __ovld get_image_num_mip_levels(write_only image2d_array_depth_t);
 int __ovld get_image_num_mip_levels(write_only image2d_depth_t);
-#endif // cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 
 #if defined(__opencl_c_read_write_images)
+#if __OPENCL_C_VERSION__ >= CL_VERSION_1_2
 int __ovld get_image_num_mip_levels(read_write image1d_array_t);
 int __ovld get_image_num_mip_levels(read_write image2d_array_t);
-#ifdef cl_khr_depth_images
+#endif // __OPENCL_C_VERSION__ >= CL_VERSION_1_2
+#if defined(__opencl_depth_image_builtins)
 int __ovld get_image_num_mip_levels(read_write image2d_array_depth_t);
 int __ovld get_image_num_mip_levels(read_write image2d_depth_t);
-#endif // cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 #endif //defined(__opencl_c_read_write_images)
 
-#endif //cl_khr_mipmap_image
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
+#endif // cl_khr_mipmap_image
+#endif // defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__)
 
 /**
  * Return the channel data type. Valid values are:
@@ -15901,10 +15956,10 @@ int __ovld __cnfn 
get_image_channel_data_type(read_only image2d_t);
 int __ovld __cnfn get_image_channel_data_type(read_only image3d_t);
 int __ovld __cnfn get_image_channel_data_type(read_only image1d_array_t);
 int __ovld __cnfn get_image_channel_data_type(read_only image2d_array_t);
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 int __ovld __cnfn get_image_channel_data_type(read_only image2d_depth_t);
 int __ovld __cnfn get_image_channel_data_type(read_only image2d_array_depth_t);
-#endif //cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 #if defined(cl_khr_gl_msaa_sharing)
 int __ovld __cnfn get_image_channel_data_type(read_only image2d_msaa_t);
 int __ovld __cnfn get_image_channel_data_type(read_only image2d_msaa_depth_t);
@@ -15920,10 +15975,10 @@ int __ovld __cnfn 
get_image_channel_data_type(write_only image3d_t);
 #endif
 int __ovld __cnfn get_image_channel_data_type(write_only image1d_array_t);
 int __ovld __cnfn get_image_channel_data_type(write_only image2d_array_t);
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 int __ovld __cnfn get_image_channel_data_type(write_only image2d_depth_t);
 int __ovld __cnfn get_image_channel_data_type(write_only 
image2d_array_depth_t);
-#endif //cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 #if defined(cl_khr_gl_msaa_sharing)
 int __ovld __cnfn get_image_channel_data_type(write_only image2d_msaa_t);
 int __ovld __cnfn get_image_channel_data_type(write_only image2d_msaa_depth_t);
@@ -15940,10 +15995,10 @@ int __ovld __cnfn 
get_image_channel_data_type(read_write image3d_t);
 #endif // cl_khr_3d_image_writes
 int __ovld __cnfn get_image_channel_data_type(read_write image1d_array_t);
 int __ovld __cnfn get_image_channel_data_type(read_write image2d_array_t);
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 int __ovld __cnfn get_image_channel_data_type(read_write image2d_depth_t);
 int __ovld __cnfn get_image_channel_data_type(read_write 
image2d_array_depth_t);
-#endif //cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 #if defined(cl_khr_gl_msaa_sharing)
 int __ovld __cnfn get_image_channel_data_type(read_write image2d_msaa_t);
 int __ovld __cnfn get_image_channel_data_type(read_write image2d_msaa_depth_t);
@@ -15975,10 +16030,10 @@ int __ovld __cnfn get_image_channel_order(read_only 
image2d_t);
 int __ovld __cnfn get_image_channel_order(read_only image3d_t);
 int __ovld __cnfn get_image_channel_order(read_only image1d_array_t);
 int __ovld __cnfn get_image_channel_order(read_only image2d_array_t);
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 int __ovld __cnfn get_image_channel_order(read_only image2d_depth_t);
 int __ovld __cnfn get_image_channel_order(read_only image2d_array_depth_t);
-#endif //cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 #if defined(cl_khr_gl_msaa_sharing)
 int __ovld __cnfn get_image_channel_order(read_only image2d_msaa_t);
 int __ovld __cnfn get_image_channel_order(read_only image2d_msaa_depth_t);
@@ -15994,10 +16049,10 @@ int __ovld __cnfn get_image_channel_order(write_only 
image3d_t);
 #endif
 int __ovld __cnfn get_image_channel_order(write_only image1d_array_t);
 int __ovld __cnfn get_image_channel_order(write_only image2d_array_t);
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 int __ovld __cnfn get_image_channel_order(write_only image2d_depth_t);
 int __ovld __cnfn get_image_channel_order(write_only image2d_array_depth_t);
-#endif //cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 #if defined(cl_khr_gl_msaa_sharing)
 int __ovld __cnfn get_image_channel_order(write_only image2d_msaa_t);
 int __ovld __cnfn get_image_channel_order(write_only image2d_msaa_depth_t);
@@ -16014,10 +16069,10 @@ int __ovld __cnfn get_image_channel_order(read_write 
image3d_t);
 #endif // cl_khr_3d_image_writes
 int __ovld __cnfn get_image_channel_order(read_write image1d_array_t);
 int __ovld __cnfn get_image_channel_order(read_write image2d_array_t);
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 int __ovld __cnfn get_image_channel_order(read_write image2d_depth_t);
 int __ovld __cnfn get_image_channel_order(read_write image2d_array_depth_t);
-#endif //cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 #if defined(cl_khr_gl_msaa_sharing)
 int __ovld __cnfn get_image_channel_order(read_write image2d_msaa_t);
 int __ovld __cnfn get_image_channel_order(read_write image2d_msaa_depth_t);
@@ -16033,10 +16088,10 @@ int __ovld __cnfn get_image_channel_order(read_write 
image2d_array_msaa_depth_t)
  */
 int2 __ovld __cnfn get_image_dim(read_only image2d_t);
 int2 __ovld __cnfn get_image_dim(read_only image2d_array_t);
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 int2 __ovld __cnfn get_image_dim(read_only image2d_array_depth_t);
 int2 __ovld __cnfn get_image_dim(read_only image2d_depth_t);
-#endif //cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 #if defined(cl_khr_gl_msaa_sharing)
 int2 __ovld __cnfn get_image_dim(read_only image2d_msaa_t);
 int2 __ovld __cnfn get_image_dim(read_only image2d_msaa_depth_t);
@@ -16046,10 +16101,10 @@ int2 __ovld __cnfn get_image_dim(read_only 
image2d_array_msaa_depth_t);
 
 int2 __ovld __cnfn get_image_dim(write_only image2d_t);
 int2 __ovld __cnfn get_image_dim(write_only image2d_array_t);
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 int2 __ovld __cnfn get_image_dim(write_only image2d_array_depth_t);
 int2 __ovld __cnfn get_image_dim(write_only image2d_depth_t);
-#endif //cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 #if defined(cl_khr_gl_msaa_sharing)
 int2 __ovld __cnfn get_image_dim(write_only image2d_msaa_t);
 int2 __ovld __cnfn get_image_dim(write_only image2d_msaa_depth_t);
@@ -16060,10 +16115,10 @@ int2 __ovld __cnfn get_image_dim(write_only 
image2d_array_msaa_depth_t);
 #if defined(__opencl_c_read_write_images)
 int2 __ovld __cnfn get_image_dim(read_write image2d_t);
 int2 __ovld __cnfn get_image_dim(read_write image2d_array_t);
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 int2 __ovld __cnfn get_image_dim(read_write image2d_array_depth_t);
 int2 __ovld __cnfn get_image_dim(read_write image2d_depth_t);
-#endif //cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 #if defined(cl_khr_gl_msaa_sharing)
 int2 __ovld __cnfn get_image_dim(read_write image2d_msaa_t);
 int2 __ovld __cnfn get_image_dim(read_write image2d_msaa_depth_t);
@@ -16092,9 +16147,9 @@ int4 __ovld __cnfn get_image_dim(read_write image3d_t);
 
 size_t __ovld __cnfn get_image_array_size(read_only image1d_array_t);
 size_t __ovld __cnfn get_image_array_size(read_only image2d_array_t);
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 size_t __ovld __cnfn get_image_array_size(read_only image2d_array_depth_t);
-#endif //cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 #if defined(cl_khr_gl_msaa_sharing)
 size_t __ovld __cnfn get_image_array_size(read_only image2d_array_msaa_t);
 size_t __ovld __cnfn get_image_array_size(read_only 
image2d_array_msaa_depth_t);
@@ -16102,9 +16157,9 @@ size_t __ovld __cnfn get_image_array_size(read_only 
image2d_array_msaa_depth_t);
 
 size_t __ovld __cnfn get_image_array_size(write_only image1d_array_t);
 size_t __ovld __cnfn get_image_array_size(write_only image2d_array_t);
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 size_t __ovld __cnfn get_image_array_size(write_only image2d_array_depth_t);
-#endif //cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 #if defined(cl_khr_gl_msaa_sharing)
 size_t __ovld __cnfn get_image_array_size(write_only image2d_array_msaa_t);
 size_t __ovld __cnfn get_image_array_size(write_only 
image2d_array_msaa_depth_t);
@@ -16113,9 +16168,9 @@ size_t __ovld __cnfn get_image_array_size(write_only 
image2d_array_msaa_depth_t)
 #if defined(__opencl_c_read_write_images)
 size_t __ovld __cnfn get_image_array_size(read_write image1d_array_t);
 size_t __ovld __cnfn get_image_array_size(read_write image2d_array_t);
-#ifdef cl_khr_depth_images
+#if defined(__opencl_depth_image_builtins)
 size_t __ovld __cnfn get_image_array_size(read_write image2d_array_depth_t);
-#endif //cl_khr_depth_images
+#endif // defined(__opencl_depth_image_builtins)
 #if defined(cl_khr_gl_msaa_sharing)
 size_t __ovld __cnfn get_image_array_size(read_write image2d_array_msaa_t);
 size_t __ovld __cnfn get_image_array_size(read_write 
image2d_array_msaa_depth_t);
@@ -18673,4 +18728,11 @@ int __ovld arm_dot_acc_sat(char4, char4, int);
 
 #undef __cnfn
 #undef __ovld
+
+#if defined(cl_khr_depth_images) || defined(__OPENCL_CPP_VERSION__) ||         
\
+    (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#undef __opencl_depth_image_builtins
+#endif // defined(cl_khr_depth_images) || defined(__OPENCL_CPP_VERSION__) ||
+       // (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+
 #endif //_OPENCL_H_
diff --git a/clang/test/Headers/opencl-c-header.cl 
b/clang/test/Headers/opencl-c-header.cl
index e26f16827b20f..0be2efce28d2f 100644
--- a/clang/test/Headers/opencl-c-header.cl
+++ b/clang/test/Headers/opencl-c-header.cl
@@ -104,47 +104,130 @@ global atomic_int z = ATOMIC_VAR_INIT(99);
 #endif //__OPENCL_C_VERSION__
 #pragma OPENCL EXTENSION cl_intel_planar_yuv : enable
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#if (defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__))
 
-#if cl_khr_subgroup_extended_types != 1
-#error "Incorrectly defined cl_khr_subgroup_extended_types"
+#if cl_khr_depth_images != 1
+#error "Incorrectly defined cl_khr_depth_images"
 #endif
-#if cl_khr_subgroup_non_uniform_vote != 1
-#error "Incorrectly defined cl_khr_subgroup_non_uniform_vote"
+#if cl_khr_extended_bit_ops != 1
+#error "Incorrectly defined cl_khr_extended_bit_ops"
+#endif
+#if cl_ext_float_atomics != 1
+#error "Incorrectly defined cl_ext_float_atomics"
+#endif
+#if cl_khr_gl_msaa_sharing != 1
+#error "Incorrectly defined cl_khr_gl_msaa_sharing"
+#endif
+#if cl_khr_integer_dot_product != 1
+#error "Incorrectly defined cl_khr_integer_dot_product"
+#endif
+#if cl_khr_kernel_clock != 1
+#error "Incorrectly defined cl_khr_kernel_clock"
+#endif
+#if cl_khr_mipmap_image != 1
+#error "Incorrectly defined cl_khr_mipmap_image"
+#endif
+#if cl_khr_mipmap_image_writes != 1
+#error "Incorrectly defined cl_khr_mipmap_image_writes"
 #endif
 #if cl_khr_subgroup_ballot != 1
 #error "Incorrectly defined cl_khr_subgroup_ballot"
 #endif
+#if cl_khr_subgroup_clustered_reduce != 1
+#error "Incorrectly defined cl_khr_subgroup_clustered_reduce"
+#endif
+#if cl_khr_subgroup_extended_types != 1
+#error "Incorrectly defined cl_khr_subgroup_extended_types"
+#endif
 #if cl_khr_subgroup_non_uniform_arithmetic != 1
 #error "Incorrectly defined cl_khr_subgroup_non_uniform_arithmetic"
 #endif
-#if cl_khr_subgroup_shuffle != 1
-#error "Incorrectly defined cl_khr_subgroup_shuffle"
+#if cl_khr_subgroup_non_uniform_vote != 1
+#error "Incorrectly defined cl_khr_subgroup_non_uniform_vote"
+#endif
+#if cl_khr_subgroup_rotate != 1
+#error "Incorrectly defined cl_khr_subgroup_rotate"
 #endif
 #if cl_khr_subgroup_shuffle_relative != 1
 #error "Incorrectly defined cl_khr_subgroup_shuffle_relative"
 #endif
-#if cl_khr_subgroup_clustered_reduce != 1
-#error "Incorrectly defined cl_khr_subgroup_clustered_reduce"
+#if cl_khr_subgroup_shuffle != 1
+#error "Incorrectly defined cl_khr_subgroup_shuffle"
 #endif
-#if cl_khr_subgroup_rotate != 1
-#error "Incorrectly defined cl_khr_subgroup_rotate"
+#if cl_khr_subgroups != 1
+#error "Incorrectly defined cl_khr_subgroups"
 #endif
-#if cl_khr_extended_bit_ops != 1
-#error "Incorrectly defined cl_khr_extended_bit_ops"
+#if cl_khr_3d_image_writes != 1
+#error "Incorrectly defined cl_khr_3d_image_writes"
 #endif
-#if cl_khr_integer_dot_product != 1
-#error "Incorrectly defined cl_khr_integer_dot_product"
+
+#else
+
+#ifdef cl_khr_depth_images
+#error "Incorrect cl_khr_depth_images define"
+#endif
+#ifdef cl_khr_extended_bit_ops
+#error "Incorrect cl_khr_extended_bit_ops define"
+#endif
+#ifdef cl_ext_float_atomics
+#error "Incorrect cl_ext_float_atomics define"
+#endif
+#ifdef cl_khr_gl_msaa_sharing
+#error "Incorrect cl_khr_gl_msaa_sharing define"
+#endif
+#ifdef cl_khr_integer_dot_product
+#error "Incorrect cl_khr_integer_dot_product define"
+#endif
+#ifdef cl_khr_kernel_clock
+#error "Incorrect cl_khr_kernel_clock define"
+#endif
+#ifdef cl_khr_mipmap_image
+#error "Incorrect cl_khr_mipmap_image define"
+#endif
+#ifdef cl_khr_mipmap_image_writes
+#error "Incorrect cl_khr_mipmap_image_writes define"
+#endif
+#ifdef cl_khr_subgroup_ballot
+#error "Incorrect cl_khr_subgroup_ballot define"
+#endif
+#ifdef cl_khr_subgroup_clustered_reduce
+#error "Incorrect cl_khr_subgroup_clustered_reduce define"
+#endif
+#ifdef cl_khr_subgroup_extended_types
+#error "Incorrect cl_khr_subgroup_extended_types define"
+#endif
+#ifdef cl_khr_subgroup_non_uniform_arithmetic
+#error "Incorrect cl_khr_subgroup_non_uniform_arithmetic define"
+#endif
+#ifdef cl_khr_subgroup_non_uniform_vote
+#error "Incorrect cl_khr_subgroup_non_uniform_vote define"
+#endif
+#ifdef cl_khr_subgroup_rotate
+#error "Incorrect cl_khr_subgroup_rotate define"
+#endif
+#ifdef cl_khr_subgroup_shuffle_relative
+#error "Incorrect cl_khr_subgroup_shuffle_relative define"
 #endif
+#ifdef cl_khr_subgroup_shuffle
+#error "Incorrect cl_khr_subgroup_shuffle define"
+#endif
+#ifdef cl_khr_subgroups
+#error "Incorrect cl_khr_subgroups define"
+#endif
+#ifdef cl_khr_3d_image_writes
+#error "Incorrect cl_khr_3d_image_writes define"
+#endif
+
+#endif // (defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__))
+
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+
 #if __opencl_c_integer_dot_product_input_4x8bit != 1
 #error "Incorrectly defined __opencl_c_integer_dot_product_input_4x8bit"
 #endif
 #if __opencl_c_integer_dot_product_input_4x8bit_packed != 1
 #error "Incorrectly defined __opencl_c_integer_dot_product_input_4x8bit_packed"
 #endif
-#if cl_ext_float_atomics != 1
-#error "Incorrectly defined cl_ext_float_atomics"
-#endif
 #if __opencl_c_ext_fp16_global_atomic_load_store != 1
 #error "Incorrectly defined __opencl_c_ext_fp16_global_atomic_load_store"
 #endif
@@ -199,45 +282,12 @@ global atomic_int z = ATOMIC_VAR_INIT(99);
 
 #else
 
-#ifdef cl_khr_subgroup_extended_types
-#error "Incorrect cl_khr_subgroup_extended_types define"
-#endif
-#ifdef cl_khr_subgroup_non_uniform_vote
-#error "Incorrect cl_khr_subgroup_non_uniform_vote define"
-#endif
-#ifdef cl_khr_subgroup_ballot
-#error "Incorrect cl_khr_subgroup_ballot define"
-#endif
-#ifdef cl_khr_subgroup_non_uniform_arithmetic
-#error "Incorrect cl_khr_subgroup_non_uniform_arithmetic define"
-#endif
-#ifdef cl_khr_subgroup_shuffle
-#error "Incorrect cl_khr_subgroup_shuffle define"
-#endif
-#ifdef cl_khr_subgroup_shuffle_relative
-#error "Incorrect cl_khr_subgroup_shuffle_relative define"
-#endif
-#ifdef cl_khr_subgroup_clustered_reduce
-#error "Incorrect cl_khr_subgroup_clustered_reduce define"
-#endif
-#ifdef cl_khr_subgroup_rotate
-#error "Incorrect cl_khr_subgroup_rotate define"
-#endif
-#ifdef cl_khr_extended_bit_ops
-#error "Incorrect cl_khr_extended_bit_ops define"
-#endif
-#ifdef cl_khr_integer_dot_product
-#error "Incorrect cl_khr_integer_dot_product define"
-#endif
 #ifdef __opencl_c_integer_dot_product_input_4x8bit
 #error "Incorrect __opencl_c_integer_dot_product_input_4x8bit define"
 #endif
 #ifdef __opencl_c_integer_dot_product_input_4x8bit_packed
 #error "Incorrect __opencl_c_integer_dot_product_input_4x8bit_packed define"
 #endif
-#ifdef cl_ext_float_atomics
-#error "Incorrect cl_ext_float_atomics define"
-#endif
 #ifdef __opencl_c_ext_fp16_global_atomic_load_store
 #error "Incorrect __opencl_c_ext_fp16_global_atomic_load_store define"
 #endif
diff --git a/clang/test/Misc/amdgcn.languageOptsOpenCL.cl 
b/clang/test/Misc/amdgcn.languageOptsOpenCL.cl
index 86b558530810e..ee33f86080e82 100644
--- a/clang/test/Misc/amdgcn.languageOptsOpenCL.cl
+++ b/clang/test/Misc/amdgcn.languageOptsOpenCL.cl
@@ -121,7 +121,7 @@
 #pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing: enable
 // expected-warning@-1{{unsupported OpenCL extension 'cl_khr_gl_msaa_sharing' 
- ignoring}}
 
-#if (__OPENCL_C_VERSION__ >= 200)
+#if defined(__OPENCL_C_VERSION__)
 #ifndef cl_khr_mipmap_image
 #error "Missing cl_khr_mipmap_image define"
 #endif
@@ -139,7 +139,7 @@
 #pragma OPENCL EXTENSION cl_khr_srgb_image_writes: enable
 // expected-warning@-1{{unsupported OpenCL extension 
'cl_khr_srgb_image_writes' - ignoring}}
 
-#if (__OPENCL_C_VERSION__ >= 200)
+#if defined(__OPENCL_C_VERSION__)
 #ifndef cl_khr_subgroups
 #error "Missing cl_khr_subgroups define"
 #endif
diff --git a/clang/test/SemaOpenCL/extension-version.cl 
b/clang/test/SemaOpenCL/extension-version.cl
index 85d7aac0e0f2a..b24c1b4bb6272 100644
--- a/clang/test/SemaOpenCL/extension-version.cl
+++ b/clang/test/SemaOpenCL/extension-version.cl
@@ -102,7 +102,7 @@
 // expected-warning@-2{{OpenCL extension 'cl_khr_3d_image_writes' is core 
feature or supported optional core feature - ignoring}}
 #endif
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 110)
+#if (defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__))
 #ifndef cles_khr_int64
 #error "Missing cles_khr_int64 define"
 #endif
@@ -111,7 +111,7 @@
 #endif
 #pragma OPENCL EXTENSION cles_khr_int64 : enable
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 100)
+#if (defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__))
 #ifndef cl_khr_gl_msaa_sharing
 #error "Missing cl_khr_gl_msaa_sharing define"
 #endif
@@ -120,7 +120,7 @@
 #endif
 #pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing : enable
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#if (defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__))
 #ifndef cl_khr_mipmap_image
 #error "Missing cl_khr_mipmap_image define"
 #endif
@@ -132,7 +132,7 @@
 #endif
 #pragma OPENCL EXTENSION cl_khr_mipmap_image : enable
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#if (defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__))
 #ifndef cl_khr_mipmap_image_writes
 #error "Missing cl_khr_mipmap_image_writes define"
 #endif
@@ -144,7 +144,7 @@
 #endif
 #pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : enable
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#if (defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__))
 #ifndef cl_khr_srgb_image_writes
 #error "Missing cl_khr_srgb_image_writes define"
 #endif
@@ -153,7 +153,7 @@
 #endif
 #pragma OPENCL EXTENSION cl_khr_srgb_image_writes : enable
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#if (defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__))
 #ifndef cl_khr_subgroups
 #error "Missing cl_khr_subgroups define"
 #endif
@@ -165,7 +165,7 @@
 #endif
 #pragma OPENCL EXTENSION cl_khr_subgroups : enable
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#if (defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__))
 #ifndef cl_ext_float_atomics
 #error "Missing cl_ext_float_atomics define"
 #endif
@@ -177,7 +177,7 @@
 // expected-warning@+1{{OpenCL extension 'cl_ext_float_atomics' unknown or 
does not require pragma - ignoring}}
 #pragma OPENCL EXTENSION cl_ext_float_atomics : enable
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#if (defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__))
 #ifndef cl_khr_extended_bit_ops
 #error "Missing cl_khr_extended_bit_ops define"
 #endif
@@ -189,7 +189,7 @@
 // expected-warning@+1{{OpenCL extension 'cl_khr_extended_bit_ops' unknown or 
does not require pragma - ignoring}}
 #pragma OPENCL EXTENSION cl_khr_extended_bit_ops : enable
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#if (defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__))
 #ifndef cl_khr_integer_dot_product
 #error "Missing cl_khr_integer_dot_product define"
 #endif
@@ -201,7 +201,7 @@
 // expected-warning@+1{{OpenCL extension 'cl_khr_integer_dot_product' unknown 
or does not require pragma - ignoring}}
 #pragma OPENCL EXTENSION cl_khr_integer_dot_product : enable
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#if (defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__))
 #ifndef cl_khr_kernel_clock
 #error "Missing cl_khr_kernel_clock define"
 #endif
@@ -213,7 +213,7 @@
 // expected-warning@+1{{OpenCL extension 'cl_khr_kernel_clock' unknown or does 
not require pragma - ignoring}}
 #pragma OPENCL EXTENSION cl_khr_kernel_clock : enable
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#if (defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__))
 #ifndef cl_khr_subgroup_ballot
 #error "Missing cl_khr_subgroup_ballot define"
 #endif
@@ -225,7 +225,7 @@
 // expected-warning@+1{{OpenCL extension 'cl_khr_subgroup_ballot' unknown or 
does not require pragma - ignoring}}
 #pragma OPENCL EXTENSION cl_khr_subgroup_ballot : enable
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#if (defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__))
 #ifndef cl_khr_subgroup_clustered_reduce
 #error "Missing cl_khr_subgroup_clustered_reduce define"
 #endif
@@ -237,7 +237,7 @@
 // expected-warning@+1{{OpenCL extension 'cl_khr_subgroup_clustered_reduce' 
unknown or does not require pragma - ignoring}}
 #pragma OPENCL EXTENSION cl_khr_subgroup_clustered_reduce : enable
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#if (defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__))
 #ifndef cl_khr_subgroup_extended_types
 #error "Missing cl_khr_subgroup_extended_types define"
 #endif
@@ -249,7 +249,7 @@
 // expected-warning@+1{{OpenCL extension 'cl_khr_subgroup_extended_types' 
unknown or does not require pragma - ignoring}}
 #pragma OPENCL EXTENSION cl_khr_subgroup_extended_types : enable
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#if (defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__))
 #ifndef cl_khr_subgroup_named_barrier
 #error "Missing cl_khr_subgroup_named_barrier define"
 #endif
@@ -261,7 +261,7 @@
 // expected-warning@+1{{OpenCL extension 'cl_khr_subgroup_named_barrier' 
unknown or does not require pragma - ignoring}}
 #pragma OPENCL EXTENSION cl_khr_subgroup_named_barrier : enable
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#if (defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__))
 #ifndef cl_khr_subgroup_non_uniform_arithmetic
 #error "Missing cl_khr_subgroup_non_uniform_arithmetic define"
 #endif
@@ -273,7 +273,7 @@
 // expected-warning@+1{{OpenCL extension 
'cl_khr_subgroup_non_uniform_arithmetic' unknown or does not require pragma - 
ignoring}}
 #pragma OPENCL EXTENSION cl_khr_subgroup_non_uniform_arithmetic : enable
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#if (defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__))
 #ifndef cl_khr_subgroup_non_uniform_vote
 #error "Missing cl_khr_subgroup_non_uniform_vote define"
 #endif
@@ -285,7 +285,7 @@
 // expected-warning@+1{{OpenCL extension 'cl_khr_subgroup_non_uniform_vote' 
unknown or does not require pragma - ignoring}}
 #pragma OPENCL EXTENSION cl_khr_subgroup_non_uniform_vote : enable
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#if (defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__))
 #ifndef cl_khr_subgroup_rotate
 #error "Missing cl_khr_subgroup_rotate define"
 #endif
@@ -297,7 +297,7 @@
 // expected-warning@+1{{OpenCL extension 'cl_khr_subgroup_rotate' unknown or 
does not require pragma - ignoring}}
 #pragma OPENCL EXTENSION cl_khr_subgroup_rotate : enable
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#if (defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__))
 #ifndef cl_khr_subgroup_shuffle_relative
 #error "Missing cl_khr_subgroup_shuffle_relative define"
 #endif
@@ -309,7 +309,7 @@
 // expected-warning@+1{{OpenCL extension 'cl_khr_subgroup_shuffle_relative' 
unknown or does not require pragma - ignoring}}
 #pragma OPENCL EXTENSION cl_khr_subgroup_shuffle_relative : enable
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#if (defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__))
 #ifndef cl_khr_subgroup_shuffle
 #error "Missing cl_khr_subgroup_shuffle define"
 #endif
@@ -331,7 +331,7 @@
 #endif
 #pragma OPENCL EXTENSION cl_amd_media_ops2 : enable
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
+#if (defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__))
 #ifndef cl_khr_depth_images
 #error "Missing cl_khr_depth_images define"
 #endif
diff --git a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl 
b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
index bf943a400320c..0ce34e6a8d0ba 100644
--- a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -72,7 +72,7 @@ typedef uint cl_mem_fence_flags;
 typedef struct {int a;} ndrange_t;
 
 // Enable extensions that are enabled in opencl-c-base.h.
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#if (defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__))
 #define __opencl_c_device_enqueue 1
 #define __opencl_c_generic_address_space 1
 #define cl_khr_subgroup_extended_types 1
@@ -299,14 +299,14 @@ kernel void basic_image_writeonly(write_only 
image1d_buffer_t image_write_only_i
 
   int4 i4;
   write_imagef(image3dwo, i4, i, f4);
-#if __OPENCL_C_VERSION__ <= CL_VERSION_1_2 && !defined(__OPENCL_CPP_VERSION__)
+#if !defined(__OPENCL_C_VERSION__) && !defined(__OPENCL_CPP_VERSION__)
   // expected-error@-2{{no matching function for call to 'write_imagef'}}
 #endif
 }
 
 kernel void basic_subgroup(global uint *out) {
   out[0] = get_sub_group_size();
-#if __OPENCL_C_VERSION__ <= CL_VERSION_1_2 && !defined(__OPENCL_CPP_VERSION__)
+#if !defined(__OPENCL_C_VERSION__) && !defined(__OPENCL_CPP_VERSION__)
   // expected-error@-2{{use of undeclared identifier 'get_sub_group_size'}}
 #endif
 
@@ -321,7 +321,7 @@ kernel void extended_subgroup(global uint4 *out, global int 
*scalar, global char
   scalar[0] = sub_group_non_uniform_scan_inclusive_or(3);
   scalar[1] = sub_group_clustered_reduce_logical_xor(2, 4);
   *c2 = sub_group_broadcast(*c2, 2);
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0 && !defined(__OPENCL_CPP_VERSION__)
+#if !defined(__OPENCL_C_VERSION__) && !defined(__OPENCL_CPP_VERSION__)
   // expected-error@-5{{use of undeclared identifier 'get_sub_group_eq_mask'}}
   // expected-error@-5{{use of undeclared identifier 
'sub_group_non_uniform_scan_inclusive_or'}}
   // expected-error@-5{{use of undeclared identifier 
'sub_group_clustered_reduce_logical_xor'}}

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to