1 // RUN: cp %s %t 2 // RUN: not %clang_cc1 -pedantic -Wunused-label -fixit -x c %t 3 // RUN: grep -v CHECK %t > %t2 4 // RUN: %clang_cc1 -pedantic -Wunused-label -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 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 30 void f1(x, y) 31 { 32 } 33 34 int i0 = { 17 }; 35 36 #define ONE 1 37 #define TWO 2 38 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 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 } 73