[PATCH] D110155: [OpenCL] Allow optional __generic in __remove_address_space utility

Justas Janickas via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 12 02:53:04 PST 2021


Topotuna updated this revision to Diff 386773.
Topotuna added a comment.
Herald added a subscriber: Naghasan.

Run line `-triple` is now set explicitly. Test moved from `CodeGenOpenCLCXX` directory to `SemaOpenCLCXX`


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110155/new/

https://reviews.llvm.org/D110155

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
  clang/test/SemaOpenCLCXX/remove-address-space.clcpp


Index: clang/test/SemaOpenCLCXX/remove-address-space.clcpp
===================================================================
--- clang/test/SemaOpenCLCXX/remove-address-space.clcpp
+++ 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 -triple spir-unknown-unknown -verify -cl-std=clc++1.0 -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -cl-std=clc++2021 -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -cl-std=clc++2021 -cl-ext=-__opencl_c_generic_address_space,-__opencl_c_pipes -fdeclare-opencl-builtins -finclude-default-header
+
+// expected-no-diagnostics
 
 template<typename T, typename U>
 struct is_same {
@@ -19,8 +23,10 @@
 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,
Index: clang/lib/Headers/opencl-c-base.h
===================================================================
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -600,9 +600,11 @@
 // 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;
 };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110155.386773.patch
Type: text/x-patch
Size: 2187 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211112/32b0f6f9/attachment.bin>


More information about the cfe-commits mailing list