File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -551,3 +551,31 @@ defdefptr = addrspace_cast<int * *>(cnstdefptr); // illegal.
551551defdefptr = reinterpret_cast<int * *>(locdefptr); // legal.
552552defdefptr = reinterpret_cast<int * *>(cnstdefptr); // legal.
553553------------
554+
555+ [[remove-addrspace]]
556+ ==== Address space removal
557+
558+ `+template<class T> struct __remove_address_space;+`
559+
560+ {cpp} for OpenCL 2021 supports utility `+__remove_address_space+` which allows to
561+ derive types that have address space qualifiers removed. Its effect is analogous
562+ to `+__remove_const+` and other similar traits in {cpp}17 `[meta.trans]`. The
563+ utility only removes an address space qualifier from a given type, therefore, other
564+ type qualifiers such as `+const+` or `+volatile+` remain unchanged.
565+
566+ [source,cpp]
567+ ----------
568+ template<typename T>
569+ void foo(T *par) {
570+ T var1; // error: function scope variable cannot be declared in global
571+ // address space
572+ __private T var2; // error: conflicting address space qualifiers are provided
573+ // between types '__private T' and '__global int'
574+ __private __remove_address_space<T>::type var3; // type of var3 is __private int
575+ }
576+
577+ void bar() {
578+ __global int* ptr;
579+ foo(ptr);
580+ }
581+ ----------
You can’t perform that action at this time.
0 commit comments