blob: bfc71291a5c3a7523e7964f277132163deb6dcbf [file] [log] [blame]
Alexander Shaposhnikov108ca942017-06-08 21:44:45 +00001// RUN: cp %s %t
2// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -fblocks -Wformat -fixit %t
3// RUN: grep -v CHECK %t | FileCheck %s
4
5/* This is a test of code modifications created by darwin format fix-its hints
6 that are provided as part of warning */
7
8int printf(const char * restrict, ...);
9
10#if __LP64__
11typedef long NSInteger;
12typedef unsigned long NSUInteger;
13#else
14typedef int NSInteger;
15typedef unsigned int NSUInteger;
16#endif
17NSInteger getNSInteger();
18NSUInteger getNSUInteger();
19
20#define Log1(...) \
21do { \
22 printf(__VA_ARGS__); \
23} while (0)
24
25#define Log2(...) \
26do { \
27 printf(__VA_ARGS__); \
28 printf(__VA_ARGS__); \
29} while (0) \
30
31#define Log3(X, Y, Z) \
32do { \
33 printf(X, Y); \
34 printf(X, Z); \
35} while (0) \
36
37void test() {
38 printf("test 1: %s", getNSInteger());
39 // CHECK: printf("test 1: %ld", (long)getNSInteger());
40 printf("test 2: %s %s", getNSInteger(), getNSInteger());
41 // CHECK: printf("test 2: %ld %ld", (long)getNSInteger(), (long)getNSInteger());
42
43 Log1("test 3: %s", getNSInteger());
44 // CHECK: Log1("test 3: %ld", (long)getNSInteger());
45 Log1("test 4: %s %s", getNSInteger(), getNSInteger());
46 // CHECK: Log1("test 4: %ld %ld", (long)getNSInteger(), (long)getNSInteger());
47
48 Log2("test 5: %s", getNSInteger());
49 // CHECK: Log2("test 5: %ld", (long)getNSInteger());
50 Log2("test 6: %s %s", getNSInteger(), getNSInteger());
51 // CHECK: Log2("test 6: %ld %ld", (long)getNSInteger(), (long)getNSInteger());
52
53 // Artificial test to check that X (in Log3(X, Y, Z))
54 // is modified only according to the diagnostics
55 // for the first printf and the modification caused
56 // by the second printf is dropped.
57 Log3("test 7: %s", getNSInteger(), getNSUInteger());
58 // CHECK: Log3("test 7: %ld", (long)getNSInteger(), (unsigned long)getNSUInteger());
59}