1 // RUN: %clang_cc1 -finclude-default-header
2 // -triple dxil-pc-shadermodel6.6-library %s -emit-llvm-only
3 // -disable-llvm-passes -verify -verify-ignore-unexpected
7 // expected-error@-1 {{no matching function for call to 'select'}}
8 // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template
9 // not viable: requires 3 arguments, but 0 were provided}}
10 // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not
11 // viable: requires 3 arguments, but 0 were provided}}
14 int test_too_few_args(bool p0) {
16 // expected-error@-1 {{no matching function for call to 'select'}}
17 // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not
18 // viable: requires 3 arguments, but 1 was provided}}
19 // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not
20 // viable: requires 3 arguments, but 1 was provided}}
23 int test_too_many_args(bool p0, int t0, int f0, int g0) {
24 return select<int>(p0, t0, f0, g0);
25 // expected-error@-1 {{no matching function for call to 'select'}}
26 // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not
27 // viable: requires 3 arguments, but 4 were provided}}
28 // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not
29 // viable: requires 3 arguments, but 4 were provided}}
32 int test_select_first_arg_wrong_type(int1 p0, int t0, int f0) {
33 return select(p0, t0, f0);
34 // expected-error@-1 {{no matching function for call to 'select'}}
35 // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not
36 // viable: no known conversion from 'vector<int, 1>' (vector of 1 'int' value)
37 // to 'bool' for 1st argument}}
38 // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored: could
39 // not match 'vector<T, Sz>' against 'int'}}
42 int1 test_select_bool_vals_diff_vecs(bool p0, int1 t0, int1 f0) {
43 return select<int1>(p0, t0, f0);
44 // expected-warning@-1 {{implicit conversion truncates vector:
45 // 'vector<int, 2>' (vector of 2 'int' values) to 'vector<int, 1>'
46 // (vector of 1 'int' value)}}
49 int2 test_select_vector_vals_not_vecs(bool2 p0, int t0,
51 return select(p0, t0, f0);
52 // expected-error@-1 {{no matching function for call to 'select'}}
53 // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored:
54 // could not match 'vector<T, Sz>' against 'int'}}
55 // expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function template not
56 // viable: no known conversion from 'vector<bool, 2>'
57 // (vector of 2 'bool' values) to 'bool' for 1st argument}}
60 int1 test_select_vector_vals_wrong_size(bool2 p0, int1 t0, int1 f0) {
61 return select<int,1>(p0, t0, f0); // produce warnings
62 // expected-warning@-1 {{implicit conversion truncates vector:
63 // 'vector<bool, 2>' (vector of 2 'bool' values) to 'vector<bool, 1>'
64 // (vector of 1 'bool' value)}}
65 // expected-warning@-2 {{implicit conversion truncates vector:
66 // 'vector<int, 2>' (vector of 2 'int' values) to 'vector<int, 1>'
67 // (vector of 1 'int' value)}}
70 // __builtin_hlsl_select tests
71 int test_select_builtin_wrong_arg_count(bool p0, int t0) {
72 return __builtin_hlsl_select(p0, t0);
73 // expected-error@-1 {{too few arguments to function call, expected 3,
77 // not a bool or a vector of bool. should be 2 errors.
78 int test_select_builtin_first_arg_wrong_type1(int p0, int t0, int f0) {
79 return __builtin_hlsl_select(p0, t0, f0);
80 // expected-error@-1 {{passing 'int' to parameter of incompatible type
82 // expected-error@-2 {{First argument to __builtin_hlsl_select must be of
86 int test_select_builtin_first_arg_wrong_type2(int1 p0, int t0, int f0) {
87 return __builtin_hlsl_select(p0, t0, f0);
88 // expected-error@-1 {{passing 'vector<int, 1>' (vector of 1 'int' value) to
89 // parameter of incompatible type 'bool'}}
90 // expected-error@-2 {{First argument to __builtin_hlsl_select must be of
94 // if a bool last 2 args are of same type
95 int test_select_builtin_bool_incompatible_args(bool p0, int t0, double f0) {
96 return __builtin_hlsl_select(p0, t0, f0);
97 // expected-error@-1 {{arguments are of different types ('int' vs 'double')}}
100 // if a vector second arg isnt a vector
101 int2 test_select_builtin_second_arg_not_vector(bool2 p0, int t0, int2 f0) {
102 return __builtin_hlsl_select(p0, t0, f0);
103 // expected-error@-1 {{Second argument to __builtin_hlsl_select must be of
107 // if a vector third arg isn't a vector
108 int2 test_select_builtin_second_arg_not_vector(bool2 p0, int2 t0, int f0) {
109 return __builtin_hlsl_select(p0, t0, f0);
110 // expected-error@-1 {{Third argument to __builtin_hlsl_select must be of
114 // if vector last 2 aren't same type (so both are vectors but wrong type)
115 int2 test_select_builtin_diff_types(bool1 p0, int1 t0, float1 f0) {
116 return __builtin_hlsl_select(p0, t0, f0);
117 // expected-error@-1 {{arguments are of different types ('vector<int, [...]>'
118 // vs 'vector<float, [...]>')}}