================
@@ -0,0 +1,93 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c23 -ffreestanding 
-fsyntax-only -verify %s
+
+#include <stdint.h>
+
+int printf(const char *restrict, ...) __attribute__((format(printf, 1, 2)));
+int scanf(const char *restrict, ...) __attribute__((format(scanf, 1, 2)));
+
+void t1(int8_t i8, uint8_t u8, int16_t i16, uint16_t u16, int32_t i32,
+        uint32_t u32, int64_t i64, uint64_t u64, int_fast8_t if8,
+        uint_fast8_t uf8, int_fast16_t if16, uint_fast16_t uf16,
+        int_fast32_t if32, uint_fast32_t uf32, int_fast64_t if64,
+        uint_fast64_t uf64) {
+  printf("%w8d", i8);
+  printf("%w8u", u8);
+  printf("%w16d", i16);
+  printf("%w16u", u16);
+  printf("%w32d", i32);
+  printf("%w32i", i32);
+  printf("%w32u", u32);
+  printf("%w32x", u32);
+  printf("%w32b", u32);
+  printf("%w64d", i64);
+  printf("%w64u", u64);
+  printf("%wf8d", if8);
+  printf("%wf8u", uf8);
+  printf("%wf16d", if16);
+  printf("%wf16u", uf16);
+  printf("%wf32d", if32);
+  printf("%wf32u", uf32);
+  printf("%wf32B", uf32);
+  printf("%wf64d", if64);
+  printf("%wf64u", uf64);
+
+  printf("%w32d", 1.0);  // expected-warning{{format specifies type 'int32_t' 
(aka 'int') but the argument has type 'double'}}
----------------
AaronBallman wrote:

Some other interesting test coverage:
```
printf("%w32d", 1);
printf("%w32d", some_int);
printf("%w16d", 1);
printf("%w16d", 65536);
printf("%w16d", some_int);
```
I don't think any of those should diagnose, at least based on existing behavior 
of specifiers like `%hd` when passed an `int` as the corresponding variadic 
argument.

But the same is not true on the `scanf` side, so test coverage there is also 
needed.

https://github.com/llvm/llvm-project/pull/199991
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to