brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · e4d370e Raw
35 lines · plain
1// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -finclude-default-header -verify -Wdouble-promotion -Wconversion %s2 3void OutVecFn(out float3) {}4void InOutVecFn(inout float3) {}5 6// Case 1: Calling out and inout parameters with types that cannot be7// back-converted. In HLSL 2021 and earlier this only occurs when passing scalar8// arguments to vector parameters because scalar->vector conversion is implicit,9// but vector->scalar is not.10void case1() {11  float f;12  int i;13  OutVecFn(f); // expected-error{{illegal scalar extension cast on argument 'f' to out paramemter}}14  InOutVecFn(f); // expected-error{{illegal scalar extension cast on argument 'f' to inout paramemter}}15 16  OutVecFn(i); // expected-error{{illegal scalar extension cast on argument 'i' to out paramemter}}17  InOutVecFn(i); // expected-error{{illegal scalar extension cast on argument 'i' to inout paramemter}}18}19 20// Case 2: Conversion warnings on argument initialization. Clang generates21// implicit conversion warnings only on the writeback conversion for `out`22// parameters since the parameter is not initialized from the argument. Clang23// generates implicit conversion warnings on both the parameter initialization24// and the writeback for `inout` parameters since the parameter is both copied25// in and out of the function.26 27void OutFloat(out float) {}28void InOutFloat(inout float) {}29 30void case2() {31  double f;32  OutFloat(f); // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}33  InOutFloat(f); // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}} expected-warning{{implicit conversion loses floating-point precision: 'double' to 'float'}}34}35