Nick Lewycky | ba5f6ec | 2010-04-24 01:30:46 +0000 | [diff] [blame] | 1 | // RUN: cp %s %t |
Richard Smith | 2315318 | 2011-09-06 03:01:15 +0000 | [diff] [blame^] | 2 | // RUN: not %clang_cc1 -pedantic -Wunused-label -fixit -x c %t |
Nick Lewycky | ba5f6ec | 2010-04-24 01:30:46 +0000 | [diff] [blame] | 3 | // RUN: grep -v CHECK %t > %t2 |
Anna Zaks | d5612a2 | 2011-07-28 20:52:06 +0000 | [diff] [blame] | 4 | // RUN: %clang_cc1 -pedantic -Wunused-label -Werror -x c %t |
Nick Lewycky | ba5f6ec | 2010-04-24 01:30:46 +0000 | [diff] [blame] | 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 | |
Argyrios Kyrtzidis | b5303aa | 2011-06-24 17:28:29 +0000 | [diff] [blame] | 36 | #define ONE 1 |
| 37 | #define TWO 2 |
| 38 | |
Chris Lattner | e5deae9 | 2010-04-20 21:33:39 +0000 | [diff] [blame] | 39 | int test_cond(int y, int fooBar) { |
| 40 | // CHECK: int x = y ? 1 : 4+fooBar; |
| 41 | int x = y ? 1 4+foobar; |
Argyrios Kyrtzidis | b5303aa | 2011-06-24 17:28:29 +0000 | [diff] [blame] | 42 | // CHECK: x = y ? ONE : TWO; |
| 43 | x = y ? ONE TWO; |
Ted Kremenek | 987aa87 | 2010-04-12 22:10:35 +0000 | [diff] [blame] | 44 | return x; |
| 45 | } |
Douglas Gregor | ae2fb14 | 2010-08-23 14:34:43 +0000 | [diff] [blame] | 46 | |
| 47 | // CHECK: typedef int int_t; |
| 48 | typedef typedef int int_t; |
Douglas Gregor | 751f692 | 2010-09-07 14:51:08 +0000 | [diff] [blame] | 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 | }; |
Argyrios Kyrtzidis | b8a9d3b | 2011-04-21 17:29:47 +0000 | [diff] [blame] | 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 | }; |
Anna Zaks | d5612a2 | 2011-07-28 20:52:06 +0000 | [diff] [blame] | 62 | |
| 63 | void removeUnusedLabels(char c) { |
| 64 | L0 /*removed comment*/: c++; |
| 65 | removeUnusedLabels(c); |
| 66 | L1: |
| 67 | c++; |
| 68 | /*preserved comment*/ L2 : c++; |
| 69 | LL |
| 70 | : c++; |
| 71 | c = c + 3; L4: return; |
| 72 | } |