|
30 | 30 | #define PAD_SIZE 16
|
31 | 31 | #define FILL_CHAR '$'
|
32 | 32 |
|
| 33 | +#define NOWARN(option, comment, block) \ |
| 34 | + __diag_push(); \ |
| 35 | + __diag_ignore_all(#option, comment); \ |
| 36 | + block \ |
| 37 | + __diag_pop(); |
| 38 | + |
33 | 39 | KSTM_MODULE_GLOBALS();
|
34 | 40 |
|
35 | 41 | static char *test_buffer __initdata;
|
@@ -159,9 +165,11 @@ test_number(void)
|
159 | 165 | test("0x1234abcd ", "%#-12x", 0x1234abcd);
|
160 | 166 | test(" 0x1234abcd", "%#12x", 0x1234abcd);
|
161 | 167 | test("0|001| 12|+123| 1234|-123|-1234", "%d|%03d|%3d|%+d|% d|%+d|% d", 0, 1, 12, 123, 1234, -123, -1234);
|
162 |
| - test("0|1|1|128|255", "%hhu|%hhu|%hhu|%hhu|%hhu", 0, 1, 257, 128, -1); |
163 |
| - test("0|1|1|-128|-1", "%hhd|%hhd|%hhd|%hhd|%hhd", 0, 1, 257, 128, -1); |
164 |
| - test("2015122420151225", "%ho%ho%#ho", 1037, 5282, -11627); |
| 168 | + NOWARN(-Wformat, "Intentionally test narrowing conversion specifiers.", { |
| 169 | + test("0|1|1|128|255", "%hhu|%hhu|%hhu|%hhu|%hhu", 0, 1, 257, 128, -1); |
| 170 | + test("0|1|1|-128|-1", "%hhd|%hhd|%hhd|%hhd|%hhd", 0, 1, 257, 128, -1); |
| 171 | + test("2015122420151225", "%ho%ho%#ho", 1037, 5282, -11627); |
| 172 | + }) |
165 | 173 | /*
|
166 | 174 | * POSIX/C99: »The result of converting zero with an explicit
|
167 | 175 | * precision of zero shall be no characters.« Hence the output
|
|
0 commit comments