1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify -triple i386-unknown-freebsd %s
2*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-unknown-freebsd %s
3*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-scei-ps4 %s
4*67e74705SXin Li
5*67e74705SXin Li // Test FreeBSD kernel printf extensions.
6*67e74705SXin Li int freebsd_kernel_printf(const char *, ...) __attribute__((__format__(__freebsd_kprintf__, 1, 2)));
7*67e74705SXin Li
check_freebsd_kernel_extensions(int i,long l,char * s,short h)8*67e74705SXin Li void check_freebsd_kernel_extensions(int i, long l, char *s, short h)
9*67e74705SXin Li {
10*67e74705SXin Li // %b expects an int and a char *
11*67e74705SXin Li freebsd_kernel_printf("reg=%b\n", i, "\10\2BITTWO\1BITONE\n"); // no-warning
12*67e74705SXin Li freebsd_kernel_printf("reg=%b\n", l, "\10\2BITTWO\1BITONE\n"); // expected-warning{{format specifies type 'int' but the argument has type 'long'}}
13*67e74705SXin Li freebsd_kernel_printf("reg=%b\n", i, l); // expected-warning{{format specifies type 'char *' but the argument has type 'long'}}
14*67e74705SXin Li freebsd_kernel_printf("reg=%b\n", i); // expected-warning{{more '%' conversions than data arguments}}
15*67e74705SXin Li freebsd_kernel_printf("reg=%b\n", i, "\10\2BITTWO\1BITONE\n", l); // expected-warning{{data argument not used by format string}}
16*67e74705SXin Li
17*67e74705SXin Li // %D expects an unsigned char * and a char *
18*67e74705SXin Li freebsd_kernel_printf("%6D", s, ":"); // no-warning
19*67e74705SXin Li freebsd_kernel_printf("%6D", i, ":"); // expected-warning{{format specifies type 'void *' but the argument has type 'int'}}
20*67e74705SXin Li freebsd_kernel_printf("%6D", s, i); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
21*67e74705SXin Li freebsd_kernel_printf("%6D", s); // expected-warning{{more '%' conversions than data arguments}}
22*67e74705SXin Li freebsd_kernel_printf("%6D", s, ":", i); // expected-warning{{data argument not used by format string}}
23*67e74705SXin Li
24*67e74705SXin Li freebsd_kernel_printf("%*D", 42, s, ":"); // no-warning
25*67e74705SXin Li freebsd_kernel_printf("%*D", 42, i, ":"); // expected-warning{{format specifies type 'void *' but the argument has type 'int'}}
26*67e74705SXin Li freebsd_kernel_printf("%*D", 42, s, i); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
27*67e74705SXin Li freebsd_kernel_printf("%*D", 42, s); // expected-warning{{more '%' conversions than data arguments}}
28*67e74705SXin Li freebsd_kernel_printf("%*D", 42, s, ":", i); // expected-warning{{data argument not used by format string}}
29*67e74705SXin Li
30*67e74705SXin Li // %r expects an int
31*67e74705SXin Li freebsd_kernel_printf("%r", i); // no-warning
32*67e74705SXin Li freebsd_kernel_printf("%r", l); // expected-warning{{format specifies type 'int' but the argument has type 'long'}}
33*67e74705SXin Li freebsd_kernel_printf("%lr", i); // expected-warning{{format specifies type 'long' but the argument has type 'int'}}
34*67e74705SXin Li freebsd_kernel_printf("%lr", l); // no-warning
35*67e74705SXin Li
36*67e74705SXin Li // h modifier expects a short
37*67e74705SXin Li freebsd_kernel_printf("%hr", i); // expected-warning{{format specifies type 'short' but the argument has type 'int'}}
38*67e74705SXin Li freebsd_kernel_printf("%hr", h); // no-warning
39*67e74705SXin Li freebsd_kernel_printf("%hy", i); // expected-warning{{format specifies type 'short' but the argument has type 'int'}}
40*67e74705SXin Li freebsd_kernel_printf("%hy", h); // no-warning
41*67e74705SXin Li
42*67e74705SXin Li // %y expects an int
43*67e74705SXin Li freebsd_kernel_printf("%y", i); // no-warning
44*67e74705SXin Li freebsd_kernel_printf("%y", l); // expected-warning{{format specifies type 'int' but the argument has type 'long'}}
45*67e74705SXin Li freebsd_kernel_printf("%ly", i); // expected-warning{{format specifies type 'long' but the argument has type 'int'}}
46*67e74705SXin Li freebsd_kernel_printf("%ly", l); // no-warning
47*67e74705SXin Li }
48