Nick Lewycky | ba5f6ec | 2010-04-24 01:30:46 +0000 | [diff] [blame] | 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 |
Douglas Gregor | 9b3064b | 2009-04-01 22:41:11 +0000 | [diff] [blame] | 6 | |
| 7 | /* This is a test of the various code modification hints that are |
Douglas Gregor | fe057ac | 2009-04-02 03:20:30 +0000 | [diff] [blame] | 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. */ |
Daniel Dunbar | d8aefab | 2009-11-17 22:25:16 +0000 | [diff] [blame] | 11 | |
| 12 | // FIXME: FIX-IT should add #include <string.h>? |
| 13 | int strcmp(const char *s1, const char *s2); |
Douglas Gregor | 9b3064b | 2009-04-01 22:41:11 +0000 | [diff] [blame] | 14 | |
| 15 | void f0(void) { }; |
| 16 | |
| 17 | struct s { |
| 18 | int x, y;; |
| 19 | }; |
| 20 | |
Daniel Dunbar | 266cc53 | 2009-11-14 19:25:21 +0000 | [diff] [blame] | 21 | // CHECK: _Complex double cd; |
Douglas Gregor | 9b3064b | 2009-04-01 22:41:11 +0000 | [diff] [blame] | 22 | _Complex cd; |
| 23 | |
Daniel Dunbar | 266cc53 | 2009-11-14 19:25:21 +0000 | [diff] [blame] | 24 | // CHECK: struct s s0 = { .y = 5 }; |
Douglas Gregor | 9b3064b | 2009-04-01 22:41:11 +0000 | [diff] [blame] | 25 | struct s s0 = { y: 5 }; |
Daniel Dunbar | 266cc53 | 2009-11-14 19:25:21 +0000 | [diff] [blame] | 26 | |
| 27 | // CHECK: int array0[5] = { [3] = 3 }; |
Douglas Gregor | 9b3064b | 2009-04-01 22:41:11 +0000 | [diff] [blame] | 28 | int array0[5] = { [3] 3 }; |
Douglas Gregor | a3a8351 | 2009-04-01 23:51:29 +0000 | [diff] [blame] | 29 | |
Nick Lewycky | ba5f6ec | 2010-04-24 01:30:46 +0000 | [diff] [blame] | 30 | void f1(x, y) |
Douglas Gregor | a3a8351 | 2009-04-01 23:51:29 +0000 | [diff] [blame] | 31 | { |
| 32 | } |
| 33 | |
| 34 | int i0 = { 17 }; |
| 35 | |
Chris Lattner | e5deae9 | 2010-04-20 21:33:39 +0000 | [diff] [blame] | 36 | int test_cond(int y, int fooBar) { |
| 37 | // CHECK: int x = y ? 1 : 4+fooBar; |
| 38 | int x = y ? 1 4+foobar; |
Ted Kremenek | 987aa87 | 2010-04-12 22:10:35 +0000 | [diff] [blame] | 39 | return x; |
| 40 | } |
Douglas Gregor | ae2fb14 | 2010-08-23 14:34:43 +0000 | [diff] [blame] | 41 | |
| 42 | // CHECK: typedef int int_t; |
| 43 | typedef typedef int int_t; |
Douglas Gregor | 751f692 | 2010-09-07 14:51:08 +0000 | [diff] [blame] | 44 | |
| 45 | // <rdar://problem/7159693> |
| 46 | enum Color { |
| 47 | Red // expected-error{{missing ',' between enumerators}} |
| 48 | Green = 17 // expected-error{{missing ',' between enumerators}} |
| 49 | Blue, |
| 50 | }; |
Argyrios Kyrtzidis | b8a9d3b | 2011-04-21 17:29:47 +0000 | [diff] [blame^] | 51 | |
| 52 | // rdar://9295072 |
| 53 | struct 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 | }; |