1*0e24686aSMital Ashok // RUN: %clang_cc1 -Wformat %s -verify 2*0e24686aSMital Ashok // RUN: %clang_cc1 -Wformat -std=c23 %s -verify 3*0e24686aSMital Ashok // RUN: %clang_cc1 -xc++ -Wformat %s -verify 4*0e24686aSMital Ashok // RUN: %clang_cc1 -xobjective-c -Wformat -fblocks %s -verify 5*0e24686aSMital Ashok // RUN: %clang_cc1 -xobjective-c++ -Wformat -fblocks %s -verify 6*0e24686aSMital Ashok // RUN: %clang_cc1 -std=c23 -Wformat %s -pedantic -verify=expected,pedantic 7*0e24686aSMital Ashok // RUN: %clang_cc1 -xc++ -Wformat %s -pedantic -verify=expected,pedantic 8*0e24686aSMital Ashok // RUN: %clang_cc1 -xobjective-c -Wformat -fblocks -pedantic %s -verify=expected,pedantic 9*0e24686aSMital Ashok 10*0e24686aSMital Ashok __attribute__((__format__(__printf__, 1, 2))) 11*0e24686aSMital Ashok int printf(const char *, ...); 12*0e24686aSMital Ashok __attribute__((__format__(__scanf__, 1, 2))) 13*0e24686aSMital Ashok int scanf(const char *, ...); 14*0e24686aSMital Ashok 15*0e24686aSMital Ashok void f(void *vp, const void *cvp, char *cp, signed char *scp, int *ip) { 16*0e24686aSMital Ashok int arr[2]; 17*0e24686aSMital Ashok 18*0e24686aSMital Ashok printf("%p", cp); 19*0e24686aSMital Ashok printf("%p", cvp); 20*0e24686aSMital Ashok printf("%p", vp); 21*0e24686aSMital Ashok printf("%p", scp); 22*0e24686aSMital Ashok printf("%p", ip); // pedantic-warning {{format specifies type 'void *' but the argument has type 'int *'}} 23*0e24686aSMital Ashok printf("%p", arr); // pedantic-warning {{format specifies type 'void *' but the argument has type 'int *'}} 24*0e24686aSMital Ashok 25*0e24686aSMital Ashok scanf("%p", &vp); 26*0e24686aSMital Ashok scanf("%p", &cvp); 27*0e24686aSMital Ashok scanf("%p", (void *volatile*)&vp); 28*0e24686aSMital Ashok scanf("%p", (const void *volatile*)&cvp); 29*0e24686aSMital Ashok scanf("%p", &cp); // pedantic-warning {{format specifies type 'void **' but the argument has type 'char **'}} 30*0e24686aSMital Ashok scanf("%p", &ip); // pedantic-warning {{format specifies type 'void **' but the argument has type 'int **'}} 31*0e24686aSMital Ashok scanf("%p", &arr); // expected-warning {{format specifies type 'void **' but the argument has type 'int (*)[2]'}} 32*0e24686aSMital Ashok 33*0e24686aSMital Ashok #if !__is_identifier(nullptr) 34*0e24686aSMital Ashok typedef __typeof__(nullptr) nullptr_t; 35*0e24686aSMital Ashok nullptr_t np = nullptr; 36*0e24686aSMital Ashok nullptr_t *npp = &np; 37*0e24686aSMital Ashok 38*0e24686aSMital Ashok printf("%p", np); 39*0e24686aSMital Ashok scanf("%p", &np); // expected-warning {{format specifies type 'void **' but the argument has type 'nullptr_t *'}} 40*0e24686aSMital Ashok scanf("%p", &npp); // pedantic-warning {{format specifies type 'void **' but the argument has type 'nullptr_t **'}} 41*0e24686aSMital Ashok #endif 42*0e24686aSMital Ashok 43*0e24686aSMital Ashok #ifdef __OBJC__ 44*0e24686aSMital Ashok id i = 0; 45*0e24686aSMital Ashok void (^b)(void) = ^{}; 46*0e24686aSMital Ashok 47*0e24686aSMital Ashok printf("%p", i); // pedantic-warning {{format specifies type 'void *' but the argument has type 'id'}} 48*0e24686aSMital Ashok printf("%p", b); // pedantic-warning {{format specifies type 'void *' but the argument has type 'void (^)(void)'}} 49*0e24686aSMital Ashok scanf("%p", &i); // pedantic-warning {{format specifies type 'void **' but the argument has type 'id *'}} 50*0e24686aSMital Ashok scanf("%p", &b); // pedantic-warning {{format specifies type 'void **' but the argument has type 'void (^*)(void)'}} 51*0e24686aSMital Ashok #endif 52*0e24686aSMital Ashok 53*0e24686aSMital Ashok } 54