|
| 1 | +// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -triple spir64-unknown-unknown -sycl-std=2020 -fsycl-int-header=%t.h %s |
| 2 | +// RUN: FileCheck -input-file=%t.h %s |
| 3 | +// |
| 4 | +// The purpose of this test is to ensure that forward declarations of free |
| 5 | +// function kernels are emitted properly. |
| 6 | +// However, this test checks a specific scenario: |
| 7 | +// - free function arguments are type aliases (through using or typedef) |
| 8 | + |
| 9 | +namespace ns { |
| 10 | + |
| 11 | +using IntUsing = int; |
| 12 | +typedef int IntTypedef; |
| 13 | + |
| 14 | +template <typename T> |
| 15 | +struct Foo {}; |
| 16 | + |
| 17 | +using FooIntUsing = Foo<int>; |
| 18 | +typedef Foo<int> FooIntTypedef; |
| 19 | + |
| 20 | +template <typename T1, typename T2> |
| 21 | +struct Bar {}; |
| 22 | + |
| 23 | +template<typename T1> |
| 24 | +using BarUsing = Bar<T1, float>; |
| 25 | + |
| 26 | +class Baz { |
| 27 | +public: |
| 28 | + using type = BarUsing<double>; |
| 29 | +}; |
| 30 | + |
| 31 | +} // namespace ns |
| 32 | + |
| 33 | +[[__sycl_detail__::add_ir_attributes_function("sycl-nd-range-kernel", 2)]] |
| 34 | +void int_using(ns::IntUsing Arg) {} |
| 35 | + |
| 36 | +// CHECK: void int_using(int Arg); |
| 37 | + |
| 38 | +[[__sycl_detail__::add_ir_attributes_function("sycl-nd-range-kernel", 2)]] |
| 39 | +void int_typedef(ns::IntTypedef Arg) {} |
| 40 | + |
| 41 | +// CHECK: void int_typedef(int Arg); |
| 42 | + |
| 43 | +[[__sycl_detail__::add_ir_attributes_function("sycl-nd-range-kernel", 2)]] |
| 44 | +void foo_using(ns::FooIntUsing Arg) {} |
| 45 | + |
| 46 | +// CHECK: void foo_using(ns::Foo<int> Arg); |
| 47 | + |
| 48 | +[[__sycl_detail__::add_ir_attributes_function("sycl-nd-range-kernel", 2)]] |
| 49 | +void foo_typedef(ns::FooIntTypedef Arg) {} |
| 50 | + |
| 51 | +// CHECK: void foo_typedef(ns::Foo<int> Arg); |
| 52 | + |
| 53 | +template<typename T> |
| 54 | +[[__sycl_detail__::add_ir_attributes_function("sycl-nd-range-kernel", 2)]] |
| 55 | +void bar_using(ns::BarUsing<T> Arg) {} |
| 56 | +template void bar_using(ns::BarUsing<int>); |
| 57 | + |
| 58 | +// CHECK: template <typename T> void bar_using(ns::Bar<T, float>); |
| 59 | + |
| 60 | +[[__sycl_detail__::add_ir_attributes_function("sycl-nd-range-kernel", 2)]] |
| 61 | +void baz_type(ns::Baz::type Arg) {} |
| 62 | + |
| 63 | +// CHECK: void baz_type(ns::Bar<double, float> Arg); |
0 commit comments