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