|
| 1 | +// Regression test for CMPLRLLVM-77544. The SYCL complex experimental |
| 2 | +// extension's inline-visibility macro previously expanded to an unguarded |
| 3 | +// __attribute__((visibility(...), always_inline)), which cl.exe cannot parse. |
| 4 | +// That surfaced when icx/clang++ drives cl.exe as the SYCL host compiler |
| 5 | +// (e.g. torch-xpu-ops builds on Windows). The header now guards the macro |
| 6 | +// with _MSC_VER; this test ensures the partial specialization of complex<T> |
| 7 | +// keeps parsing under MSVC host compilation. |
| 8 | + |
| 9 | +// RUN: %clangxx -fsycl -fsycl-host-compiler=cl -fsycl-host-compiler-options='/std:c++20 /MD /EHsc /permissive- /DSYCL_DISABLE_FSYCL_SYCLHPP_WARNING' %s -c -o %t.o |
| 10 | +// REQUIRES: windows |
| 11 | + |
| 12 | +#define SYCL_EXT_ONEAPI_COMPLEX |
| 13 | +#include <sycl/ext/oneapi/experimental/complex/complex.hpp> |
| 14 | +#include <sycl/sycl.hpp> |
| 15 | + |
| 16 | +namespace syclex = sycl::ext::oneapi::experimental; |
| 17 | + |
| 18 | +// Force instantiation of the complex<T, enable_if<is_genfloat<T>>> partial |
| 19 | +// specialization for each supported floating-point type. Prior to the fix, |
| 20 | +// simply parsing the class body under cl.exe hit C2059 on the first member |
| 21 | +// decorated with _SYCL_EXT_CPLX_INLINE_VISIBILITY. |
| 22 | +void force_instantiate() { |
| 23 | + syclex::complex<float> zf(1.0f, 2.0f); |
| 24 | + syclex::complex<double> zd(1.0, 2.0); |
| 25 | + syclex::complex<sycl::half> zh(sycl::half{1.0f}, sycl::half{2.0f}); |
| 26 | + (void)syclex::exp(zf).real(); |
| 27 | + (void)syclex::exp(zd).real(); |
| 28 | + (void)syclex::exp(zh).real(); |
| 29 | +} |
0 commit comments