[clang] b5fef6d - [OpenCL] Allow optional __generic in __remove_address_space utility

Justas Janickas via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 27 01:11:15 PST 2021


Author: Justas Janickas
Date: 2021-12-27T08:39:21Z
New Revision: b5fef6dbfd6b4c84d61155fd2221064bcc1ecdcf

URL: https://github.com/llvm/llvm-project/commit/b5fef6dbfd6b4c84d61155fd2221064bcc1ecdcf
DIFF: https://github.com/llvm/llvm-project/commit/b5fef6dbfd6b4c84d61155fd2221064bcc1ecdcf.diff

LOG: [OpenCL] Allow optional __generic in __remove_address_space utility

Added: 
    clang/test/SemaOpenCLCXX/remove-address-space.clcpp

Modified: 
    clang/lib/Headers/opencl-c-base.h

Removed: 
    clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp


################################################################################
diff  --git a/clang/lib/Headers/opencl-c-base.h b/clang/lib/Headers/opencl-c-base.h
index 9c81ddb5e2a73..7485386c82346 100644
--- a/clang/lib/Headers/opencl-c-base.h
+++ b/clang/lib/Headers/opencl-c-base.h
@@ -600,9 +600,11 @@ typedef struct {
 // C++ for OpenCL - __remove_address_space
 #if defined(__OPENCL_CPP_VERSION__)
 template <typename _Tp> struct __remove_address_space { using type = _Tp; };
+#if defined(__opencl_c_generic_address_space)
 template <typename _Tp> struct __remove_address_space<__generic _Tp> {
   using type = _Tp;
 };
+#endif
 template <typename _Tp> struct __remove_address_space<__global _Tp> {
   using type = _Tp;
 };

diff  --git a/clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp b/clang/test/SemaOpenCLCXX/remove-address-space.clcpp
similarity index 75%
rename from clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
rename to clang/test/SemaOpenCLCXX/remove-address-space.clcpp
index f6f0c3290aa66..e6b2924eab5f8 100644
--- a/clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
+++ b/clang/test/SemaOpenCLCXX/remove-address-space.clcpp
@@ -1,4 +1,8 @@
-// RUN: %clang_cc1 %s -cl-std=clc++ -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -cl-std=clc++1.0 -triple spir-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header -verify
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -triple spir-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header -verify
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -cl-ext=-__opencl_c_generic_address_space,-__opencl_c_pipes -triple spir-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header -verify
+
+// expected-no-diagnostics
 
 template<typename T, typename U>
 struct is_same {
@@ -19,8 +23,10 @@ void test_is_same() {
 void test_remove_address_space() {
   static_assert(is_same<__remove_address_space<int>::type, int>::value,
                 "type without an address space unexpectedly modified by __remove_address_space");
+#if defined(__opencl_c_generic_address_space)
   static_assert(is_same<__remove_address_space<__generic int>::type, int>::value,
                 "__generic address space not removed by __remove_address_space");
+#endif
   static_assert(is_same<__remove_address_space<__global char>::type, char>::value,
                 "__global address space not removed by __remove_address_space");
   static_assert(is_same<__remove_address_space<__private ulong>::type, ulong>::value,


        


More information about the cfe-commits mailing list