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