1// RUN: %clang_cc1 -cl-std=CL1.2 -cl-ext=+cl_khr_fp64 -fsyntax-only -verify %s 2// RUN: %clang_cc1 -cl-std=CL1.2 -cl-ext=-cl_khr_fp64 -fsyntax-only -verify %s 3 4typedef __attribute__((ext_vector_type(4))) half half4; 5 6typedef __attribute__((ext_vector_type(2))) float float2; 7typedef __attribute__((ext_vector_type(4))) float float4; 8 9#ifdef cl_khr_fp64 10typedef __attribute__((ext_vector_type(4))) double double4; 11#endif 12 13typedef __attribute__((ext_vector_type(4))) char char4; 14typedef __attribute__((ext_vector_type(4))) unsigned char uchar4; 15 16typedef __attribute__((ext_vector_type(4))) short short4; 17typedef __attribute__((ext_vector_type(4))) unsigned short ushort4; 18 19typedef __attribute__((ext_vector_type(2))) int int2; 20typedef __attribute__((ext_vector_type(4))) int int4; 21typedef __attribute__((ext_vector_type(16))) int int16; 22 23typedef __attribute__((ext_vector_type(4))) long long4; 24typedef __attribute__((ext_vector_type(4))) unsigned int uint4; 25typedef __attribute__((ext_vector_type(4))) unsigned long ulong4; 26 27int printf(__constant const char* st, ...) __attribute__((format(printf, 1, 2))); 28 29 30#ifdef cl_khr_fp64 31kernel void format_v4f64(half4 arg_h, float4 arg_f, double4 arg_d) 32{ 33 printf("%v4lf", arg_d); 34 printf("%v4lf", arg_f); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}} 35 printf("%v4lf", arg_h); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'half4' (vector of 4 'half' values)}} 36 37 printf("%v4lF", arg_d); 38 printf("%v4lF", arg_f); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}} 39 printf("%v4lF", arg_h); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'half4' (vector of 4 'half' values)}} 40 41 printf("%v4le", arg_d); 42 printf("%v4le", arg_f); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}} 43 printf("%v4le", arg_h); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'half4' (vector of 4 'half' values)}} 44 45 printf("%v4lE", arg_d); 46 printf("%v4lE", arg_f); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}} 47 printf("%v4lE", arg_h); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'half4' (vector of 4 'half' values)}} 48 49 printf("%v4lg", arg_d); 50 printf("%v4lg", arg_f); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}} 51 printf("%v4lg", arg_h); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'half4' (vector of 4 'half' values)}} 52 53 printf("%v4lG", arg_d); 54 printf("%v4lG", arg_f); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}} 55 printf("%v4lG", arg_h); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'half4' (vector of 4 'half' values)}} 56 57 printf("%v4la", arg_d); 58 printf("%v4la", arg_f); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}} 59 printf("%v4la", arg_h); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'half4' (vector of 4 'half' values)}} 60 61 printf("%v4lA", arg_d); 62 printf("%v4lA", arg_f); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}} 63 printf("%v4lA", arg_h); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'half4' (vector of 4 'half' values)}} 64} 65 66kernel void format_v4f16(half4 arg_h, float4 arg_f, double4 arg_d) 67{ 68 printf("%v4hf\n", arg_d); // expected-warning{{format specifies type 'half __attribute__((ext_vector_type(4)))' but the argument has type 'double4' (vector of 4 'double' values)}} 69 printf("%v4hf\n", arg_f); // expected-warning{{format specifies type 'half __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}} 70 printf("%v4hf\n", arg_h); 71} 72 73kernel void no_length_modifier_scalar_fp(float f) { 74 printf("%hf", f); // expected-warning{{length modifier 'h' results in undefined behavior or no effect with 'f' conversion specifier}} 75 printf("%hlf", f); // expected-warning{{length modifier 'hl' results in undefined behavior or no effect with 'f' conversion specifier}} 76 printf("%lf", f); // expected-warning{{length modifier 'l' results in undefined behavior or no effect with 'f' conversion specifier}} 77} 78 79#endif 80 81kernel void format_v4f32(float4 arg) 82{ 83#ifdef cl_khr_fp64 84 printf("%v4f\n", arg); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}} 85 86 // Precision modifier 87 printf("%.2v4f\n", arg); //expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}} 88#else 89 // FIXME: These should not warn, and the type should be expected to be float. 90 printf("%v4f\n", arg); // expected-warning {{double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}} 91 92 // Precision modifier 93 printf("%.2v4f\n", arg); // expected-warning {{double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}} 94#endif 95} 96 97kernel void format_only_v(int arg) 98{ 99 printf("%v", arg); // expected-warning {{incomplete format specifier}} 100} 101 102kernel void format_missing_num(int arg) 103{ 104 printf("%v4", arg); // expected-warning {{incomplete format specifier}} 105} 106 107kernel void format_not_num(int arg) 108{ 109 printf("%vNd", arg); // expected-warning {{incomplete format specifier}} 110 printf("%v*d", arg); // expected-warning {{incomplete format specifier}} 111} 112 113kernel void format_v16i32(int16 arg) 114{ 115 printf("%v16d\n", arg); 116} 117 118kernel void format_v4i32_scalar(int arg) 119{ 120 printf("%v4d\n", arg); // expected-warning {{format specifies type 'int __attribute__((ext_vector_type(4)))' but the argument has type 'int'}} 121} 122 123kernel void format_v4i32_wrong_num_elts_2_to_4(int2 arg) 124{ 125 printf("%v4d\n", arg); // expected-warning {{format specifies type 'int __attribute__((ext_vector_type(4)))' but the argument has type 'int2' (vector of 2 'int' values)}} 126} 127 128kernel void format_missing_num_elts_format(int4 arg) 129{ 130 printf("%vd\n", arg); // expected-warning {{incomplete format specifier}} 131} 132 133kernel void format_v4f32_scalar(float arg) 134{ 135 printf("%v4f\n", arg); // expected-warning {{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'float'}} 136} 137 138kernel void format_v4f32_wrong_num_elts(float2 arg) 139{ 140 printf("%v4f\n", arg); // expected-warning {{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'float2' (vector of 2 'float' values)}} 141} 142 143kernel void format_missing_num_elts(float4 arg) 144{ 145 printf("%vf\n", arg); // expected-warning {{incomplete format specifier}} 146} 147 148kernel void vector_precision_modifier_v4i32_to_v4f32(int4 arg) 149{ 150 printf("%.2v4f\n", arg); // expected-warning {{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'int4' (vector of 4 'int' values)}} 151} 152 153kernel void invalid_Y(int4 arg) 154{ 155 printf("%v4Y\n", arg); // expected-warning {{invalid conversion specifier 'Y'}} 156} 157 158// FIXME: This should warn 159kernel void crash_on_s(int4 arg) 160{ 161 printf("%v4s\n", arg); 162} 163 164 165kernel void printf_int_length_modifiers(char4 arg_c, short4 arg_s, int4 arg_i, long4 arg_l, uchar4 arg_uc, ushort4 arg_us, uint4 arg_ui, ulong4 arg_ul) { 166 printf("%v4hhd", arg_c); 167 printf("%v4hhd", arg_s); 168 printf("%v4hhd", arg_i); 169 printf("%v4hhd", arg_l); 170 171 printf("%v4hd", arg_c); // expected-warning{{format specifies type 'short __attribute__((ext_vector_type(4)))' but the argument has type 'char4' (vector of 4 'char' values)}} 172 printf("%v4hd", arg_s); 173 printf("%v4hd", arg_i); // expected-warning{{format specifies type 'short __attribute__((ext_vector_type(4)))' but the argument has type 'int4' (vector of 4 'int' values)}} 174 printf("%v4hd", arg_l); // expected-warning{{format specifies type 'short __attribute__((ext_vector_type(4)))' but the argument has type 'long4' (vector of 4 'long' values)}} 175 176 printf("%v4hld", arg_c); // expected-warning{{format specifies type 'int __attribute__((ext_vector_type(4)))' but the argument has type 'char4' (vector of 4 'char' values)}} 177 printf("%v4hld", arg_s); // expected-warning{{format specifies type 'int __attribute__((ext_vector_type(4)))' but the argument has type 'short4' (vector of 4 'short' values)}} 178 printf("%v4hld", arg_i); 179 printf("%v4hld", arg_l); // expected-warning{{format specifies type 'int __attribute__((ext_vector_type(4)))' but the argument has type 'long4' (vector of 4 'long' values)}} 180 181 printf("%v4ld", arg_c); // expected-warning{{format specifies type 'long __attribute__((ext_vector_type(4)))' but the argument has type 'char4' (vector of 4 'char' values)}} 182 printf("%v4ld", arg_s); // expected-warning{{format specifies type 'long __attribute__((ext_vector_type(4)))' but the argument has type 'short4' (vector of 4 'short' values)}} 183 printf("%v4ld", arg_i); // expected-warning{{format specifies type 'long __attribute__((ext_vector_type(4)))' but the argument has type 'int4' (vector of 4 'int' values)}} 184 printf("%v4ld", arg_l); 185 186 187 188 printf("%v4hhu", arg_uc); 189 printf("%v4hhu", arg_us); // expected-warning{{format specifies type 'unsigned char __attribute__((ext_vector_type(4)))' but the argument has type 'ushort4' (vector of 4 'unsigned short' values)}} 190 printf("%v4hhu", arg_ui); // expected-warning{{format specifies type 'unsigned char __attribute__((ext_vector_type(4)))' but the argument has type 'uint4' (vector of 4 'unsigned int' values)}} 191 printf("%v4hhu", arg_ul); // expected-warning{{format specifies type 'unsigned char __attribute__((ext_vector_type(4)))' but the argument has type 'ulong4' (vector of 4 'unsigned long' values)}} 192 193 printf("%v4hu", arg_uc); // expected-warning{{format specifies type 'unsigned short __attribute__((ext_vector_type(4)))' but the argument has type 'uchar4' (vector of 4 'unsigned char' values)}} 194 printf("%v4hu", arg_us); 195 printf("%v4hu", arg_ui); // expected-warning{{format specifies type 'unsigned short __attribute__((ext_vector_type(4)))' but the argument has type 'uint4' (vector of 4 'unsigned int' values)}} 196 printf("%v4hu", arg_ul); // expected-warning{{format specifies type 'unsigned short __attribute__((ext_vector_type(4)))' but the argument has type 'ulong4' (vector of 4 'unsigned long' values)}} 197 198 printf("%v4hlu", arg_uc); // expected-warning{{format specifies type 'unsigned int __attribute__((ext_vector_type(4)))' but the argument has type 'uchar4' (vector of 4 'unsigned char' values)}} 199 printf("%v4hlu", arg_us); // expected-warning{{format specifies type 'unsigned int __attribute__((ext_vector_type(4)))' but the argument has type 'ushort4' (vector of 4 'unsigned short' values)}} 200 printf("%v4hlu", arg_ui); 201 printf("%v4hlu", arg_ul); // expected-warning{{format specifies type 'unsigned int __attribute__((ext_vector_type(4)))' but the argument has type 'ulong4' (vector of 4 'unsigned long' values)}} 202 203 printf("%v4lu", arg_uc); // expected-warning{{format specifies type 'unsigned long __attribute__((ext_vector_type(4)))' but the argument has type 'uchar4' (vector of 4 'unsigned char' values)}} 204 printf("%v4lu", arg_us); // expected-warning{{format specifies type 'unsigned long __attribute__((ext_vector_type(4)))' but the argument has type 'ushort4' (vector of 4 'unsigned short' values)}} 205 printf("%v4lu", arg_ui); // expected-warning{{format specifies type 'unsigned long __attribute__((ext_vector_type(4)))' but the argument has type 'uint4' (vector of 4 'unsigned int' values)}} 206 printf("%v4lu", arg_ul); 207 208 209 printf("%v4n", &arg_i); // expected-warning{{invalid conversion specifier 'n'}} 210 printf("%v4hln", &arg_i); // expected-warning{{invalid conversion specifier 'n'}} 211} 212