[clang][SYCL] Fix integration header for free function kernels with enum values in args#21278
[clang][SYCL] Fix integration header for free function kernels with enum values in args#21278dklochkov-emb wants to merge 7 commits intosyclfrom
Conversation
…unction-enum-issue
Fznamznon
left a comment
There was a problem hiding this comment.
I'm just curious about what it will print for something like
enum class A : int {
B,
C
};
template <A a, typename B> struct C{
};
void freefunctionkernel(C<static_cast<A>(38), int> cc);
[SYCL] decrease small string size
Integration header will contain something like this: void freefunctionkernel(C<static_cast(38), int> cc); |
|
|
I did not manage to compile with this example both cases - within the range and out of it: However, when I set something easier and closer to bugs: |
This pull request fixes the problem of using
enumvalue names with free functions.Context of the problem:
Free function kernels use integration header to create shim functions. It is added forward declarations for this. I.e. if we have some free function kernel:
Wee need to emit its declaration into integration header because user sources are not "available" from header:
void some_kernel_func(some_args);However, if any of arguments(
some_args) are classes, structs etc we need to emit their forward declarationsUsing
enumdoes not produce problems but usingenumvalue names emits build error because compiler does not allow to use forward declaration of particularenumvalue, i.e.it is not allowed to use forward declaration of
A::A0This pull request adds workaround solution of the problem: every
enumvalue name is replaced with its value casted toenumtype during sema analysis. I.e.A::A1 is replaced with static_cast<A>(1);