@@ -195,6 +195,44 @@ T buzz(int X, T Y) {
195195 return X + Y;
196196}
197197
198+ // Case 4: Verify that the parameter modifier attributes are instantiated
199+ // for both templated and non-templated arguments, and that the non-templated
200+ // out argument type is not modified by the template instantiation.
201+
202+ // CHECK-LABEL: FunctionTemplateDecl {{.*}} fizz_two
203+
204+ // Check the pattern decl.
205+ // CHECK: FunctionDecl {{.*}} fizz_two 'void (inout T, out int)'
206+ // CHECK-NEXT: ParmVarDecl {{.*}} referenced V 'T'
207+ // CHECK-NEXT: HLSLParamModifierAttr {{.*}} inout
208+ // CHECK-NEXT: ParmVarDecl {{.*}} referenced I 'int &__restrict'
209+ // CHECK-NEXT: HLSLParamModifierAttr {{.*}} out
210+
211+ // Check the 3 instantiations (int, float, & double).
212+
213+ // CHECK-LABEL: FunctionDecl {{.*}} used fizz_two 'void (inout int, out int)' implicit_instantiation
214+ // CHECK: ParmVarDecl {{.*}} used V 'int &__restrict'
215+ // CHECK-NEXT: HLSLParamModifierAttr {{.*}} inout
216+ // CHECK: ParmVarDecl {{.*}} used I 'int &__restrict'
217+ // CHECK-NEXT: HLSLParamModifierAttr {{.*}} out
218+
219+ // CHECK-LABEL: FunctionDecl {{.*}} used fizz_two 'void (inout float, out int)' implicit_instantiation
220+ // CHECK: ParmVarDecl {{.*}} used V 'float &__restrict'
221+ // CHECK-NEXT: HLSLParamModifierAttr {{.*}} inout
222+ // CHECK: ParmVarDecl {{.*}} used I 'int &__restrict'
223+ // CHECK-NEXT: HLSLParamModifierAttr {{.*}} out
224+
225+ // CHECK-LABEL: FunctionDecl {{.*}} used fizz_two 'void (inout double, out int)' implicit_instantiation
226+ // CHECK: ParmVarDecl {{.*}} used V 'double &__restrict'
227+ // CHECK-NEXT: HLSLParamModifierAttr {{.*}} inout
228+ // CHECK: ParmVarDecl {{.*}} used I 'int &__restrict'
229+ // CHECK-NEXT: HLSLParamModifierAttr {{.*}} out
230+ template <typename T>
231+ void fizz_two (inout T V, out int I) {
232+ V += 2 ;
233+ I = V;
234+ }
235+
198236export void caller () {
199237 int X = 2 ;
200238 float Y = 3.3 ;
@@ -211,4 +249,8 @@ export void caller() {
211249 X = buzz (X, X);
212250 Y = buzz (X, Y);
213251 Z = buzz (X, Z);
252+
253+ fizz_two (X, X);
254+ fizz_two (Y, X);
255+ fizz_two (Z, X);
214256}
0 commit comments