blob: 1a6ef635570a57e031e09d74488f8b13b46cf643 [file] [log] [blame]
Nick Lewyckyba5f6ec2010-04-24 01:30:46 +00001// 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
Douglas Gregor9b3064b2009-04-01 22:41:11 +00006
7/* This is a test of the various code modification hints that are
Douglas Gregorfe057ac2009-04-02 03:20:30 +00008 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. */
Daniel Dunbard8aefab2009-11-17 22:25:16 +000011
12// FIXME: FIX-IT should add #include <string.h>?
13int strcmp(const char *s1, const char *s2);
Douglas Gregor9b3064b2009-04-01 22:41:11 +000014
15void f0(void) { };
16
17struct s {
18 int x, y;;
19};
20
Daniel Dunbar266cc532009-11-14 19:25:21 +000021// CHECK: _Complex double cd;
Douglas Gregor9b3064b2009-04-01 22:41:11 +000022_Complex cd;
23
Daniel Dunbar266cc532009-11-14 19:25:21 +000024// CHECK: struct s s0 = { .y = 5 };
Douglas Gregor9b3064b2009-04-01 22:41:11 +000025struct s s0 = { y: 5 };
Daniel Dunbar266cc532009-11-14 19:25:21 +000026
27// CHECK: int array0[5] = { [3] = 3 };
Douglas Gregor9b3064b2009-04-01 22:41:11 +000028int array0[5] = { [3] 3 };
Douglas Gregora3a83512009-04-01 23:51:29 +000029
Nick Lewyckyba5f6ec2010-04-24 01:30:46 +000030void f1(x, y)
Douglas Gregora3a83512009-04-01 23:51:29 +000031{
32}
33
34int i0 = { 17 };
35
Chris Lattnere5deae92010-04-20 21:33:39 +000036int test_cond(int y, int fooBar) {
37// CHECK: int x = y ? 1 : 4+fooBar;
38 int x = y ? 1 4+foobar;
Ted Kremenek987aa872010-04-12 22:10:35 +000039 return x;
40}
Douglas Gregorae2fb142010-08-23 14:34:43 +000041
42// CHECK: typedef int int_t;
43typedef typedef int int_t;
Douglas Gregor751f6922010-09-07 14:51:08 +000044
45// <rdar://problem/7159693>
46enum Color {
47 Red // expected-error{{missing ',' between enumerators}}
48 Green = 17 // expected-error{{missing ',' between enumerators}}
49 Blue,
50};
Argyrios Kyrtzidisb8a9d3b2011-04-21 17:29:47 +000051
52// rdar://9295072
53struct test_struct {
54 // CHECK: struct test_struct *struct_ptr;
55 test_struct *struct_ptr; // expected-error {{must use 'struct' tag to refer to type 'test_struct'}}
56};