xref: /llvm-project/clang/test/SemaHLSL/BuiltIns/length-errors.hlsl (revision b900379e26d9f49977c4d772f1b2b681fc5147d4)
1// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify
2
3void test_too_few_arg()
4{
5  return length();
6  // expected-error@-1 {{no matching function for call to 'length'}}
7  // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function not viable: requires single argument 'X', but no arguments were provided}}
8  // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function not viable: requires single argument 'X', but no arguments were provided}}
9  // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires single argument 'X', but no arguments were provided}}
10  // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires single argument 'X', but no arguments were provided}}
11}
12
13void test_too_many_arg(float2 p0)
14{
15  return length(p0, p0);
16  // expected-error@-1 {{no matching function for call to 'length'}}
17  // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function not viable: requires single argument 'X', but 2 arguments were provided}}
18  // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires single argument 'X', but 2 arguments were provided}}
19  // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function not viable: requires single argument 'X', but 2 arguments were provided}}
20  // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not viable: requires single argument 'X', but 2 arguments were provided}}
21}
22
23float double_to_float_type(double p0) {
24  return length(p0);
25  // expected-error@-1  {{call to 'length' is ambiguous}}
26  // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function}}
27  // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function}}
28}
29
30
31float bool_to_float_type_promotion(bool p1)
32{
33  return length(p1);
34  // expected-error@-1  {{call to 'length' is ambiguous}}
35  // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function}}
36  // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function}}
37}
38
39float length_int_to_float_promotion(int p1)
40{
41  return length(p1);
42  // expected-error@-1  {{call to 'length' is ambiguous}}
43  // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function}}
44  // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function}}
45}
46
47float2 length_int2_to_float2_promotion(int2 p1)
48{
49  return length(p1);
50  // expected-error@-1  {{call to 'length' is ambiguous}}
51  // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function}}
52  // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function}}
53}
54