blob: 6c206bac04762c373bb3985247b117e02b212d1c [file] [log] [blame]
Erik Pilkingtonf7766b1e2019-10-04 19:20:27 +00001// RUN: %clang_cc1 -fsyntax-only -verify -Wno-format -Wformat-pedantic %s
2// RUN: %clang_cc1 -xobjective-c -fblocks -fsyntax-only -verify -Wno-format -Wformat-pedantic %s
3// RUN: %clang_cc1 -xc++ -fsyntax-only -verify -Wno-format -Wformat-pedantic %s
Nathan Huckleberrycc01d642019-08-23 18:01:57 +00004
Erik Pilkingtonf7766b1e2019-10-04 19:20:27 +00005__attribute__((format(printf, 1, 2)))
Nathan Huckleberrycc01d642019-08-23 18:01:57 +00006int printf(const char *restrict, ...);
7
Erik Pilkingtonf7766b1e2019-10-04 19:20:27 +00008int main() {
9 printf("%p", (int *)0); // expected-warning {{format specifies type 'void *' but the argument has type 'int *'}}
10 printf("%p", (void *)0);
Nathan Huckleberrycc01d642019-08-23 18:01:57 +000011
Erik Pilkingtonf7766b1e2019-10-04 19:20:27 +000012#ifdef __OBJC__
13 printf("%p", ^{}); // expected-warning {{format specifies type 'void *' but the argument has type 'void (^)(void)'}}
14 printf("%p", (id)0); // expected-warning {{format specifies type 'void *' but the argument has type 'id'}}
15#endif
16
17#ifdef __cplusplus
18 printf("%p", nullptr); // expected-warning {{format specifies type 'void *' but the argument has type 'nullptr_t'}}
19#endif
Nathan Huckleberrycc01d642019-08-23 18:01:57 +000020}