diff --git a/proposals/0043-groupshared-arguments.md b/proposals/0043-groupshared-arguments.md index 23200357..3ebf0f14 100644 --- a/proposals/0043-groupshared-arguments.md +++ b/proposals/0043-groupshared-arguments.md @@ -133,6 +133,51 @@ void caller() { } ``` +### Templates + +```c++ +template +void fnT(T A, T B) { + A = B; +} +``` + +In Clang, given the above template, the following explicit instantiation should produce +a template instantiation with groupshared uint for both parameters. +In DXC, `groupshared` is not currently treated as a type qualifier in all situations +making the below example ignore the `groupshared` annotation on `uint`. DXC produces +this warning: +"warning: 'groupshared' attribute ignored when parsing type [-Wignored-attributes]". + +```c++ +groupshared uint Shared; +void caller() { + fnT(Shared, Shared); +} +``` + +In Clang and DXC, given the above template, the following instantiation which requires deduction +should produce a template instantiation that ignores that `Shared` is groupshared +because type qualifiers are ignored when performing type deduction for template +instantiation. + +```c++ +groupshared uint Shared; +void caller() { + fnT(Shared, Shared); +} +``` + +The below example is supported by both Clang and DXC and every instantiation of this template +has a groupshared argument. + +```c++ +template +T fnT(groupshared T A) { + return A; +} +``` + ### Errors and Warnings The `groupshared` type annotation keyword will be allowed on function parameter