blob: 212e1f8981cbefa4fd39975f1905b28c7bb68a36 [file] [log] [blame]
Matt Arsenault0ff50d42018-12-01 22:16:27 +00001// 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 Arsenaulte19dc612018-11-13 22:30:35 +00003
4typedef __attribute__((ext_vector_type(2))) float float2;
5typedef __attribute__((ext_vector_type(4))) float float4;
Matt Arsenault0ff50d42018-12-01 22:16:27 +00006
7typedef __attribute__((ext_vector_type(2))) int int2;
Matt Arsenaulte19dc612018-11-13 22:30:35 +00008typedef __attribute__((ext_vector_type(4))) int int4;
Matt Arsenault0ff50d42018-12-01 22:16:27 +00009typedef __attribute__((ext_vector_type(16))) int int16;
Matt Arsenaulte19dc612018-11-13 22:30:35 +000010
11int printf(__constant const char* st, ...) __attribute__((format(printf, 1, 2)));
12
13kernel void format_v4f32(float4 arg)
14{
Matt Arsenault0ff50d42018-12-01 22:16:27 +000015#ifdef cl_khr_fp64
Matt Arsenault297afb12019-01-29 20:49:47 +000016 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 Arsenault0ff50d42018-12-01 22:16:27 +000017
18 // Precision modifier
Matt Arsenault297afb12019-01-29 20:49:47 +000019 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 Arsenault0ff50d42018-12-01 22:16:27 +000020#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
29kernel void format_only_v(int arg)
30{
31 printf("%v", arg); // expected-warning {{incomplete format specifier}}
32}
33
34kernel void format_missing_num(int arg)
35{
36 printf("%v4", arg); // expected-warning {{incomplete format specifier}}
37}
38
39kernel 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
45kernel void format_v16i32(int16 arg)
46{
47 printf("%v16d\n", arg);
48}
49
50kernel 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
55kernel 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
60kernel void format_missing_num_elts_format(int4 arg)
61{
62 printf("%vd\n", arg); // expected-warning {{incomplete format specifier}}
63}
64
65kernel 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 Arsenaulte19dc612018-11-13 22:30:35 +000068}
69
70kernel void format_v4f32_wrong_num_elts(float2 arg)
71{
Matt Arsenault0ff50d42018-12-01 22:16:27 +000072 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 Arsenaulte19dc612018-11-13 22:30:35 +000073}
74
Matt Arsenaulte19dc612018-11-13 22:30:35 +000075kernel void format_missing_num_elts(float4 arg)
76{
Matt Arsenault0ff50d42018-12-01 22:16:27 +000077 printf("%vf\n", arg); // expected-warning {{incomplete format specifier}}
78}
79
80kernel 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
85kernel void invalid_Y(int4 arg)
86{
87 printf("%v4Y\n", arg); // expected-warning {{invalid conversion specifier 'Y'}}
Matt Arsenaulte19dc612018-11-13 22:30:35 +000088}
89
90// FIXME: This should warn
Matt Arsenault0ff50d42018-12-01 22:16:27 +000091kernel void crash_on_s(int4 arg)
Matt Arsenaulte19dc612018-11-13 22:30:35 +000092{
Matt Arsenault0ff50d42018-12-01 22:16:27 +000093 printf("%v4s\n", arg);
Matt Arsenaulte19dc612018-11-13 22:30:35 +000094}