Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[C++4OpenCL] Introduces __remove_address_space utility
This change provides a way to conveniently declare types that have address space qualifiers removed. Since OpenCL adds address spaces implicitly even when they are not specified in source, it is useful to allow deriving address space unqualified types. Fixes llvm.org/PR45326 Differential Revision: https://reviews.llvm.org/D106785
- Loading branch information
Showing
3 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// RUN: %clang_cc1 %s -cl-std=clc++ -fdeclare-opencl-builtins -finclude-default-header | ||
|
||
template<typename T, typename U> | ||
struct is_same { | ||
static const bool value = false; | ||
}; | ||
|
||
template<typename T> | ||
struct is_same<T, T> { | ||
static const bool value = true; | ||
}; | ||
|
||
void test_is_same() { | ||
static_assert(is_same<int, int>::value); | ||
static_assert(!is_same<int, float>::value); | ||
static_assert(!is_same<__private int, int>::value); | ||
} | ||
|
||
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"); | ||
static_assert(is_same<__remove_address_space<__generic int>::type, int>::value, | ||
"__generic address space not removed by __remove_address_space"); | ||
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, | ||
"__private address space not removed by __remove_address_space"); | ||
static_assert(is_same<__remove_address_space<__local short>::type, short>::value, | ||
"__local address space not removed by __remove_address_space"); | ||
static_assert(is_same<__remove_address_space<__constant int3>::type, int3>::value, | ||
"__constant address space not removed by __remove_address_space"); | ||
static_assert(is_same<__remove_address_space<const volatile __global int>::type, const volatile int>::value, | ||
"non-address-space qualifiers inappropriately removed by __remove_address_space"); | ||
} |