1 // RUN: %clang_cc1 -Wformat %s -verify
2 // RUN: %clang_cc1 -Wformat -std=c23 %s -verify
3 // RUN: %clang_cc1 -xc++ -Wformat %s -verify
4 // RUN: %clang_cc1 -xobjective-c -Wformat -fblocks %s -verify
5 // RUN: %clang_cc1 -xobjective-c++ -Wformat -fblocks %s -verify
6 // RUN: %clang_cc1 -std=c23 -Wformat %s -pedantic -verify=expected,pedantic
7 // RUN: %clang_cc1 -xc++ -Wformat %s -pedantic -verify=expected,pedantic
8 // RUN: %clang_cc1 -xobjective-c -Wformat -fblocks -pedantic %s -verify=expected,pedantic
10 __attribute__((__format__(__printf__
, 1, 2)))
11 int printf(const char *, ...);
12 __attribute__((__format__(__scanf__
, 1, 2)))
13 int scanf(const char *, ...);
15 void f(void *vp
, const void *cvp
, char *cp
, signed char *scp
, int *ip
) {
22 printf("%p", ip
); // pedantic-warning {{format specifies type 'void *' but the argument has type 'int *'}}
23 printf("%p", arr
); // pedantic-warning {{format specifies type 'void *' but the argument has type 'int *'}}
27 scanf("%p", (void *volatile*)&vp
);
28 scanf("%p", (const void *volatile*)&cvp
);
29 scanf("%p", &cp
); // pedantic-warning {{format specifies type 'void **' but the argument has type 'char **'}}
30 scanf("%p", &ip
); // pedantic-warning {{format specifies type 'void **' but the argument has type 'int **'}}
31 scanf("%p", &arr
); // expected-warning {{format specifies type 'void **' but the argument has type 'int (*)[2]'}}
33 #if !__is_identifier(nullptr)
34 typedef __typeof__(nullptr) nullptr_t
;
35 nullptr_t np
= nullptr;
39 scanf("%p", &np
); // expected-warning {{format specifies type 'void **' but the argument has type 'nullptr_t *'}}
40 scanf("%p", &npp
); // pedantic-warning {{format specifies type 'void **' but the argument has type 'nullptr_t **'}}
45 void (^b
)(void) = ^{};
47 printf("%p", i
); // pedantic-warning {{format specifies type 'void *' but the argument has type 'id'}}
48 printf("%p", b
); // pedantic-warning {{format specifies type 'void *' but the argument has type 'void (^)(void)'}}
49 scanf("%p", &i
); // pedantic-warning {{format specifies type 'void **' but the argument has type 'id *'}}
50 scanf("%p", &b
); // pedantic-warning {{format specifies type 'void **' but the argument has type 'void (^*)(void)'}}