summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaOpenCL/printf-format-strings.cl
blob: d5748e18edee9f287f5a9ca0f5d2904708017e23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// RUN: %clang_cc1 -cl-std=CL1.2 -fsyntax-only -verify %s

typedef __attribute__((ext_vector_type(2))) float float2;
typedef __attribute__((ext_vector_type(4))) float float4;
typedef __attribute__((ext_vector_type(4))) int int4;

int printf(__constant const char* st, ...) __attribute__((format(printf, 1, 2)));

kernel void format_v4f32(float4 arg)
{
    printf("%v4f\n", arg); // expected-no-diagnostics
}

kernel void format_v4f32_wrong_num_elts(float2 arg)
{
    printf("%v4f\n", arg); // expected-no-diagnostics
}

kernel void vector_precision_modifier_v4f32(float4 arg)
{
    printf("%.2v4f\n", arg); // expected-no-diagnostics
}

// FIXME: This should warn
kernel void format_missing_num_elts(float4 arg)
{
    printf("%vf\n", arg); // expected-no-diagnostics
}

// FIXME: This should warn
kernel void vector_precision_modifier_v4i32(int4 arg)
{
    printf("%.2v4f\n", arg); // expected-no-diagnostics
}
OpenPOWER on IntegriCloud