brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.1 KiB · 3d3ed6b Raw
49 lines · c
1// RUN: %clang_cc1 -fsyntax-only -verify -triple i386-unknown-freebsd %s2// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-unknown-freebsd %s3// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-scei-ps4 %s4// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-sie-ps5 %s5 6// Test FreeBSD kernel printf extensions.7int freebsd_kernel_printf(const char *, ...) __attribute__((__format__(__freebsd_kprintf__, 1, 2)));8 9void check_freebsd_kernel_extensions(int i, long l, char *s, short h)10{11  // %b expects an int and a char *12  freebsd_kernel_printf("reg=%b\n", i, "\10\2BITTWO\1BITONE\n"); // no-warning13  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}}17 18  // %D expects an unsigned char * and a char *19  freebsd_kernel_printf("%6D", s, ":"); // no-warning20  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}}24 25  freebsd_kernel_printf("%*D", 42, s, ":"); // no-warning26  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}}30 31  // %r expects an int32  freebsd_kernel_printf("%r", i); // no-warning33  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-warning36 37  // h modifier expects a short38  freebsd_kernel_printf("%hr", i); // no-warning39  freebsd_kernel_printf("%hr", h); // no-warning40  freebsd_kernel_printf("%hy", i); // no-warning41  freebsd_kernel_printf("%hy", h); // no-warning42 43  // %y expects an int44  freebsd_kernel_printf("%y", i); // no-warning45  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-warning48}49