Debian Codegraph @

clang/test/SemaHLSL/BuiltIns/dot-errors.hlsl

raw
1 // RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -fnative-int16-type -emit-llvm-only -disable-llvm-passes -verify -verify-ignore-unexpected=note
2
3 float test_no_second_arg(float2 p0) {
4 return __builtin_hlsl_dot(p0);
5 // expected-error@-1 {{too few arguments to function call, expected 2, have 1}}
6 }
7
8 float test_too_many_arg(float2 p0) {
9 return __builtin_hlsl_dot(p0, p0, p0);
10 // expected-error@-1 {{too many arguments to function call, expected 2, have 3}}
11 }
12
13 float test_dot_no_second_arg(float2 p0) {
14 return dot(p0);
15 // expected-error@-1 {{no matching function for call to 'dot'}}
16 }
17
18 float test_dot_vector_size_mismatch(float3 p0, float2 p1) {
19 return dot(p0, p1);
20 // expected-error@-1 {{arguments are of different types ('vector<[...], 3>' vs 'vector<[...], 2>')}}
21 }
22
23 float test_dot_builtin_vector_size_mismatch(float3 p0, float2 p1) {
24 return __builtin_hlsl_dot(p0, p1);
25 // expected-error@-1 {{arguments are of different types ('vector<[...], 3>' vs 'vector<[...], 2>')}}
26 }
27
28 float test_dot_scalar_mismatch(float p0, int p1) {
29 return dot(p0, p1);
30 // expected-error@-1 {{call to 'dot' is ambiguous}}
31 }
32
33 float test_dot_element_type_mismatch(int2 p0, float2 p1) {
34 return dot(p0, p1);
35 // expected-error@-1 {{call to 'dot' is ambiguous}}
36 }
37
38 //NOTE: for all the *_promotion we are intentionally not handling type promotion in builtins
39 float test_builtin_dot_vec_int_to_float_promotion(int2 p0, float2 p1) {
40 return __builtin_hlsl_dot(p0, p1);
41 // expected-error@-1 {{arguments are of different types ('vector<int, [...]>' vs 'vector<float, [...]>')}}
42 }
43
44 int64_t test_builtin_dot_vec_int_to_int64_promotion(int64_t2 p0, int2 p1) {
45 return __builtin_hlsl_dot(p0, p1);
46 // expected-error@-1 {{arguments are of different types ('vector<int64_t, [...]>' vs 'vector<int, [...]>')}}
47 }
48
49 float test_builtin_dot_vec_half_to_float_promotion(float2 p0, half2 p1) {
50 return __builtin_hlsl_dot(p0, p1);
51 // expected-error@-1 {{arguments are of different types ('vector<float, [...]>' vs 'vector<half, [...]>')}}
52 }
53
54 #ifdef __HLSL_ENABLE_16_BIT
55 float test_builtin_dot_vec_int16_to_float_promotion(float2 p0, int16_t2 p1) {
56 return __builtin_hlsl_dot(p0, p1);
57 // expected-error@-1 {{arguments are of different types ('vector<float, [...]>' vs 'vector<int16_t, [...]>')}}
58 }
59
60 half test_builtin_dot_vec_int16_to_half_promotion(half2 p0, int16_t2 p1) {
61 return __builtin_hlsl_dot(p0, p1);
62 // expected-error@-1 {{arguments are of different types ('vector<half, [...]>' vs 'vector<int16_t, [...]>')}}
63 }
64
65 int test_builtin_dot_vec_int16_to_int_promotion(int2 p0, int16_t2 p1) {
66 return __builtin_hlsl_dot(p0, p1);
67 // expected-error@-1 {{arguments are of different types ('vector<int, [...]>' vs 'vector<int16_t, [...]>')}}
68 }
69
70 int64_t test_builtin_dot_vec_int16_to_int64_promotion(int64_t2 p0,
71 int16_t2 p1) {
72 return __builtin_hlsl_dot(p0, p1);
73 // expected-error@-1 {{arguments are of different types ('vector<int64_t, [...]>' vs 'vector<int16_t, [...]>')}}
74 }
75 #endif
76
77 float test_builtin_dot_float2_splat(float p0, float2 p1) {
78 return __builtin_hlsl_dot(p0, p1);
79 // expected-error@-1 {{arguments are of different types ('float' vs 'float2' (aka 'vector<float, 2>'))}}
80 }
81
82 float test_builtin_dot_float3_splat(float p0, float3 p1) {
83 return __builtin_hlsl_dot(p0, p1);
84 // expected-error@-1 {{arguments are of different types ('float' vs 'float3' (aka 'vector<float, 3>'))}}
85 }
86
87 float test_builtin_dot_float4_splat(float p0, float4 p1) {
88 return __builtin_hlsl_dot(p0, p1);
89 // expected-error@-1 {{arguments are of different types ('float' vs 'float4' (aka 'vector<float, 4>'))}}
90 }
91
92 float test_dot_float2_int_splat(float2 p0, int p1) {
93 return __builtin_hlsl_dot(p0, p1);
94 // expected-error@-1 {{arguments are of different types ('float2' (aka 'vector<float, 2>') vs 'int')}}
95 }
96
97 float test_dot_float3_int_splat(float3 p0, int p1) {
98 return __builtin_hlsl_dot(p0, p1);
99 // expected-error@-1 {{arguments are of different types ('float3' (aka 'vector<float, 3>') vs 'int')}}
100 }
101
102 float test_builtin_dot_int_vect_to_float_vec_promotion(int2 p0, float p1) {
103 return __builtin_hlsl_dot(p0, p1);
104 // expected-error@-1 {{arguments are of different types ('int2' (aka 'vector<int, 2>') vs 'float')}}
105 }
106
107 int test_builtin_dot_bool_type_promotion(bool p0, float p1) {
108 return __builtin_hlsl_dot(p0, p1);
109 // expected-error@-1 {{1st argument must be a vector, integer or floating-point type (was 'bool')}}
110 }
111
112 double test_dot_double(double2 p0, double2 p1) {
113 return dot(p0, p1);
114 // expected-error@-1 {{call to 'dot' is ambiguous}}
115 }
116
117 double test_dot_double_builtin(double2 p0, double2 p1) {
118 return __builtin_hlsl_dot(p0, p1);
119 // expected-error@-1 {{1st argument must be a scalar floating-point type (was 'double2' (aka 'vector<double, 2>'))}}
120 }
121
122 float builtin_bool_to_float_type_promotion ( float p0, bool p1 ) {
123 return __builtin_hlsl_dot ( p0, p1 );
124 // expected-error@-1 {{are of different types ('float' vs 'bool')}}
125 }
126
127 float builtin_dot_int_to_float_promotion ( float p0, int p1 ) {
128 return __builtin_hlsl_dot (p0, p1 );
129 // expected-error@-1 {{are of different types ('float' vs 'int')}}
130 }