Matt Arsenault | 0ff50d4 | 2018-12-01 22:16:27 +0000 | [diff] [blame] | 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 |
Matt Arsenault | e19dc61 | 2018-11-13 22:30:35 +0000 | [diff] [blame] | 3 | |
| 4 | typedef __attribute__((ext_vector_type(2))) float float2; |
| 5 | typedef __attribute__((ext_vector_type(4))) float float4; |
Matt Arsenault | 0ff50d4 | 2018-12-01 22:16:27 +0000 | [diff] [blame] | 6 | |
| 7 | typedef __attribute__((ext_vector_type(2))) int int2; |
Matt Arsenault | e19dc61 | 2018-11-13 22:30:35 +0000 | [diff] [blame] | 8 | typedef __attribute__((ext_vector_type(4))) int int4; |
Matt Arsenault | 0ff50d4 | 2018-12-01 22:16:27 +0000 | [diff] [blame] | 9 | typedef __attribute__((ext_vector_type(16))) int int16; |
Matt Arsenault | e19dc61 | 2018-11-13 22:30:35 +0000 | [diff] [blame] | 10 | |
| 11 | int printf(__constant const char* st, ...) __attribute__((format(printf, 1, 2))); |
| 12 | |
| 13 | kernel void format_v4f32(float4 arg) |
| 14 | { |
Matt Arsenault | 0ff50d4 | 2018-12-01 22:16:27 +0000 | [diff] [blame] | 15 | #ifdef cl_khr_fp64 |
Matt Arsenault | 297afb1 | 2019-01-29 20:49:47 +0000 | [diff] [blame^] | 16 | 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)}} |
Matt Arsenault | 0ff50d4 | 2018-12-01 22:16:27 +0000 | [diff] [blame] | 17 | |
| 18 | // Precision modifier |
Matt Arsenault | 297afb1 | 2019-01-29 20:49:47 +0000 | [diff] [blame^] | 19 | 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)}} |
Matt Arsenault | 0ff50d4 | 2018-12-01 22:16:27 +0000 | [diff] [blame] | 20 | #else |
| 21 | // FIXME: These should not warn, and the type should be expected to be float. |
| 22 | printf("%v4f\n", arg); // expected-warning {{double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}} |
| 23 | |
| 24 | // Precision modifier |
| 25 | printf("%.2v4f\n", arg); // expected-warning {{double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}} |
| 26 | #endif |
| 27 | } |
| 28 | |
| 29 | kernel void format_only_v(int arg) |
| 30 | { |
| 31 | printf("%v", arg); // expected-warning {{incomplete format specifier}} |
| 32 | } |
| 33 | |
| 34 | kernel void format_missing_num(int arg) |
| 35 | { |
| 36 | printf("%v4", arg); // expected-warning {{incomplete format specifier}} |
| 37 | } |
| 38 | |
| 39 | kernel void format_not_num(int arg) |
| 40 | { |
| 41 | printf("%vNd", arg); // expected-warning {{incomplete format specifier}} |
| 42 | printf("%v*d", arg); // expected-warning {{incomplete format specifier}} |
| 43 | } |
| 44 | |
| 45 | kernel void format_v16i32(int16 arg) |
| 46 | { |
| 47 | printf("%v16d\n", arg); |
| 48 | } |
| 49 | |
| 50 | kernel void format_v4i32_scalar(int arg) |
| 51 | { |
| 52 | printf("%v4d\n", arg); // expected-warning {{format specifies type 'int __attribute__((ext_vector_type(4)))' but the argument has type 'int'}} |
| 53 | } |
| 54 | |
| 55 | kernel void format_v4i32_wrong_num_elts_2_to_4(int2 arg) |
| 56 | { |
| 57 | 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)}} |
| 58 | } |
| 59 | |
| 60 | kernel void format_missing_num_elts_format(int4 arg) |
| 61 | { |
| 62 | printf("%vd\n", arg); // expected-warning {{incomplete format specifier}} |
| 63 | } |
| 64 | |
| 65 | kernel void format_v4f32_scalar(float arg) |
| 66 | { |
| 67 | printf("%v4f\n", arg); // expected-warning {{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'float'}} |
Matt Arsenault | e19dc61 | 2018-11-13 22:30:35 +0000 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | kernel void format_v4f32_wrong_num_elts(float2 arg) |
| 71 | { |
Matt Arsenault | 0ff50d4 | 2018-12-01 22:16:27 +0000 | [diff] [blame] | 72 | 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)}} |
Matt Arsenault | e19dc61 | 2018-11-13 22:30:35 +0000 | [diff] [blame] | 73 | } |
| 74 | |
Matt Arsenault | e19dc61 | 2018-11-13 22:30:35 +0000 | [diff] [blame] | 75 | kernel void format_missing_num_elts(float4 arg) |
| 76 | { |
Matt Arsenault | 0ff50d4 | 2018-12-01 22:16:27 +0000 | [diff] [blame] | 77 | printf("%vf\n", arg); // expected-warning {{incomplete format specifier}} |
| 78 | } |
| 79 | |
| 80 | kernel void vector_precision_modifier_v4i32_to_v4f32(int4 arg) |
| 81 | { |
| 82 | 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)}} |
| 83 | } |
| 84 | |
| 85 | kernel void invalid_Y(int4 arg) |
| 86 | { |
| 87 | printf("%v4Y\n", arg); // expected-warning {{invalid conversion specifier 'Y'}} |
Matt Arsenault | e19dc61 | 2018-11-13 22:30:35 +0000 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | // FIXME: This should warn |
Matt Arsenault | 0ff50d4 | 2018-12-01 22:16:27 +0000 | [diff] [blame] | 91 | kernel void crash_on_s(int4 arg) |
Matt Arsenault | e19dc61 | 2018-11-13 22:30:35 +0000 | [diff] [blame] | 92 | { |
Matt Arsenault | 0ff50d4 | 2018-12-01 22:16:27 +0000 | [diff] [blame] | 93 | printf("%v4s\n", arg); |
Matt Arsenault | e19dc61 | 2018-11-13 22:30:35 +0000 | [diff] [blame] | 94 | } |