annotate clang/test/Sema/format-strings-pedantic.c @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900 (2021-06-07)
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-format -Wformat-pedantic %s
anatofuz
parents:
diff changeset
2 // RUN: %clang_cc1 -xobjective-c -fblocks -fsyntax-only -verify -Wno-format -Wformat-pedantic %s
anatofuz
parents:
diff changeset
3 // RUN: %clang_cc1 -xc++ -fsyntax-only -verify -Wno-format -Wformat-pedantic %s
anatofuz
parents:
diff changeset
4
anatofuz
parents:
diff changeset
5 __attribute__((format(printf, 1, 2)))
anatofuz
parents:
diff changeset
6 int printf(const char *restrict, ...);
anatofuz
parents:
diff changeset
7
anatofuz
parents:
diff changeset
8 int main() {
anatofuz
parents:
diff changeset
9 printf("%p", (int *)0); // expected-warning {{format specifies type 'void *' but the argument has type 'int *'}}
anatofuz
parents:
diff changeset
10 printf("%p", (void *)0);
anatofuz
parents:
diff changeset
11
anatofuz
parents:
diff changeset
12 #ifdef __OBJC__
anatofuz
parents:
diff changeset
13 printf("%p", ^{}); // expected-warning {{format specifies type 'void *' but the argument has type 'void (^)(void)'}}
anatofuz
parents:
diff changeset
14 printf("%p", (id)0); // expected-warning {{format specifies type 'void *' but the argument has type 'id'}}
anatofuz
parents:
diff changeset
15 #endif
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 #ifdef __cplusplus
anatofuz
parents:
diff changeset
18 printf("%p", nullptr); // expected-warning {{format specifies type 'void *' but the argument has type 'nullptr_t'}}
anatofuz
parents:
diff changeset
19 #endif
anatofuz
parents:
diff changeset
20 }