gcc/testsuite/gcc.dg/format/sentinel-2.c
raw| 1 | /* PR c/114780 */ |
| 2 | /* { dg-do compile } */ |
| 3 | /* { dg-options "-std=c23 -Wformat" } */ |
| 4 | |
| 5 | #include <stddef.h> |
| 6 | |
| 7 | [[gnu::sentinel]] void foo (int, ...); |
| 8 | [[gnu::sentinel]] void bar (...); |
| 9 | |
| 10 | void |
| 11 | baz (nullptr_t p) |
| 12 | { |
| 13 | foo (1, 2, nullptr); |
| 14 | foo (3, 4, 5, p); |
| 15 | bar (nullptr); |
| 16 | bar (p); |
| 17 | foo (6, 7, 0); // { dg-warning "missing sentinel in function call" } |
| 18 | bar (0); // { dg-warning "missing sentinel in function call" } |
| 19 | foo (8, 9, NULL); |
| 20 | bar (NULL); |
| 21 | } |