================
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -fsycl-is-device -triple spirv64-unknown-unknown 
-fsyntax-only -verify=sycl -DSYCL %s
+// RUN: %clang_cc1 -fsycl-is-host -triple x86_64-unknown-linux-gnu 
-fsyntax-only -verify=sycl -DSYCL %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only 
-verify=nosycl %s
+
+
+#ifdef SYCL
+// The builtin returns a pointer to unsigned char in local address space.
+static_assert(__is_same(decltype(__builtin_sycl_dynamic_local_memory()),
+                        unsigned char [[clang::sycl_local]] *));
+
+void conversions() {
+  // Implicit conversion to a generic pointer is allowed.
+  unsigned char *Generic = __builtin_sycl_dynamic_local_memory();
+
+  // Casting to a pointer to another type in the local address space.
+  float [[clang::sycl_local]] *F =
+      reinterpret_cast<float [[clang::sycl_local]] *>(
+          __builtin_sycl_dynamic_local_memory() + 16);
+
+  // sycl-error@+1 {{cannot initialize a variable of type 'char *' with an 
rvalue of type '[[clang::sycl_local]] unsigned char *'}}
+  char *C = __builtin_sycl_dynamic_local_memory();
+}
----------------
tahonermann wrote:

Here too I think exercising the conversions (and the template tests below) 
doesn't exercise anything specific to the builtin. The `__is_same` check and 
the test for too many arguments are great. I suggest moving the availability 
check to its own test to prevent some future someone messing with the `RUN` 
lines from accidentally invalidating that part of the test. That would also 
avoid need for the custom check prefixes.

https://github.com/llvm/llvm-project/pull/244373
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to