diff --git a/clang/lib/Headers/opencl-c-base.h b/clang/lib/Headers/opencl-c-base.h --- a/clang/lib/Headers/opencl-c-base.h +++ b/clang/lib/Headers/opencl-c-base.h @@ -30,7 +30,7 @@ #endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) // Define feature macros for OpenCL C 2.0 -#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200) +#if (__OPENCL_CPP_VERSION__ == 100 || __OPENCL_C_VERSION__ == 200) #define __opencl_c_pipes 1 #define __opencl_c_generic_address_space 1 #define __opencl_c_work_group_collective_functions 1 @@ -45,12 +45,12 @@ #endif // Define header-only feature macros for OpenCL C 3.0. -#if (__OPENCL_C_VERSION__ == 300) +#if (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) // For the SPIR target all features are supported. #if defined(__SPIR__) #define __opencl_c_atomic_scope_all_devices 1 #endif // defined(__SPIR__) -#endif // (__OPENCL_C_VERSION__ == 300) +#endif // (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) // built-in scalar data types: diff --git a/clang/test/Headers/opencl-c-header.cl b/clang/test/Headers/opencl-c-header.cl --- a/clang/test/Headers/opencl-c-header.cl +++ b/clang/test/Headers/opencl-c-header.cl @@ -175,13 +175,13 @@ #endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) // OpenCL C features. -#if (__OPENCL_C_VERSION__ == 300) +#if (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) #if __opencl_c_atomic_scope_all_devices != 1 #error "Incorrectly defined feature macro __opencl_c_atomic_scope_all_devices" #endif -#elif (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200) +#elif (__OPENCL_CPP_VERSION__ == 100 || __OPENCL_C_VERSION__ == 200) #ifndef __opencl_c_pipes #error "Feature macro __opencl_c_pipes should be defined" @@ -262,6 +262,6 @@ #error "Incorrect feature macro __opencl_c_subgroups define" #endif -#endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200) +#endif // (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) #endif // defined(__SPIR__) diff --git a/clang/test/SemaOpenCL/features.cl b/clang/test/SemaOpenCL/features.cl --- a/clang/test/SemaOpenCL/features.cl +++ b/clang/test/SemaOpenCL/features.cl @@ -6,6 +6,14 @@ // RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES // RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL3.0 -cl-ext=+all \ // RUN: | FileCheck -match-full-lines %s --check-prefix=FEATURES +// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++2021 -cl-ext=-all \ +// RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES +// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++2021 -cl-ext=+all \ +// RUN: | FileCheck -match-full-lines %s --check-prefix=FEATURES +// RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++2021 \ +// RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES +// RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++2021 -cl-ext=+all \ +// RUN: | FileCheck -match-full-lines %s --check-prefix=FEATURES // For OpenCL C 2.0 feature macros are defined only in header, so test that earlier OpenCL // versions don't define feature macros accidentally and CL2.0 don't define them without header @@ -15,7 +23,7 @@ // RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES // RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL2.0 \ // RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES -// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CLC++ \ +// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++1.0 \ // RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES // Note that __opencl_c_int64 is always defined assuming