1 // RUN: cp %s %t
2 // RUN: %clang_cc1 -pedantic -fixit -x c %t || true
3 // RUN: grep -v CHECK %t > %t2
4 // RUN: %clang_cc1 -pedantic -Werror -x c %t
5 // RUN: FileCheck -input-file=%t2 %t
6
7 /* This is a test of the various code modification hints that are
8 provided as part of warning or extension diagnostics. All of the
9 warnings will be fixed by -fixit, and the resulting file should
10 compile cleanly with -Werror -pedantic. */
11
12 // FIXME: FIX-IT should add #include <string.h>?
13 int strcmp(const char *s1, const char *s2);
14
f0(void)15 void f0(void) { };
16
17 struct s {
18 int x, y;;
19 };
20
21 // CHECK: _Complex double cd;
22 _Complex cd;
23
24 // CHECK: struct s s0 = { .y = 5 };
25 struct s s0 = { y: 5 };
26
27 // CHECK: int array0[5] = { [3] = 3 };
28 int array0[5] = { [3] 3 };
29
f1(x,y)30 void f1(x, y)
31 {
32 }
33
34 int i0 = { 17 };
35
36 #define ONE 1
37 #define TWO 2
38
test_cond(int y,int fooBar)39 int test_cond(int y, int fooBar) {
40 // CHECK: int x = y ? 1 : 4+fooBar;
41 int x = y ? 1 4+foobar;
42 // CHECK: x = y ? ONE : TWO;
43 x = y ? ONE TWO;
44 return x;
45 }
46
47 // CHECK: typedef int int_t;
48 typedef typedef int int_t;
49
50 // <rdar://problem/7159693>
51 enum Color {
52 Red // expected-error{{missing ',' between enumerators}}
53 Green = 17 // expected-error{{missing ',' between enumerators}}
54 Blue,
55 };
56
57 // rdar://9295072
58 struct test_struct {
59 // CHECK: struct test_struct *struct_ptr;
60 test_struct *struct_ptr; // expected-error {{must use 'struct' tag to refer to type 'test_struct'}}
61 };
62