1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*0a6a1f1dSLionel Sambuc // RUN: cp %s %t
3*0a6a1f1dSLionel Sambuc // RUN: not %clang_cc1 -fixit %t -x c -DFIXIT
4*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only %t -x c -DFIXIT
5*0a6a1f1dSLionel Sambuc // RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -strict-whitespace
6*0a6a1f1dSLionel Sambuc
test1()7*0a6a1f1dSLionel Sambuc void test1() {
8*0a6a1f1dSLionel Sambuc int a[] = {0,1,1,2,3};
9*0a6a1f1dSLionel Sambuc int []b = {0,1,4,9,16};
10*0a6a1f1dSLionel Sambuc // expected-error@-1{{brackets go after the identifier}}
11*0a6a1f1dSLionel Sambuc // CHECK: {{^}} int []b = {0,1,4,9,16};
12*0a6a1f1dSLionel Sambuc // CHECK: {{^}} ~~ ^
13*0a6a1f1dSLionel Sambuc // CHECK: {{^}} []
14*0a6a1f1dSLionel Sambuc // CHECK: fix-it:{{.*}}:{[[@LINE-5]]:7-[[@LINE-5]]:9}:""
15*0a6a1f1dSLionel Sambuc // CHECK: fix-it:{{.*}}:{[[@LINE-6]]:10-[[@LINE-6]]:10}:"[]"
16*0a6a1f1dSLionel Sambuc
17*0a6a1f1dSLionel Sambuc int c = a[0];
18*0a6a1f1dSLionel Sambuc int d = b[0]; // No undeclared identifer error here.
19*0a6a1f1dSLionel Sambuc
20*0a6a1f1dSLionel Sambuc int *e = a;
21*0a6a1f1dSLionel Sambuc int *f = b; // No undeclared identifer error here.
22*0a6a1f1dSLionel Sambuc }
23*0a6a1f1dSLionel Sambuc
24*0a6a1f1dSLionel Sambuc struct S {
25*0a6a1f1dSLionel Sambuc int [1][1]x;
26*0a6a1f1dSLionel Sambuc // expected-error@-1{{brackets go after the identifier}}
27*0a6a1f1dSLionel Sambuc // CHECK: {{^}} int [1][1]x;
28*0a6a1f1dSLionel Sambuc // CHECK: {{^}} ~~~~~~ ^
29*0a6a1f1dSLionel Sambuc // CHECK: {{^}} [1][1]
30*0a6a1f1dSLionel Sambuc // CHECK: fix-it:{{.*}}:{[[@LINE-5]]:7-[[@LINE-5]]:13}:""
31*0a6a1f1dSLionel Sambuc // CHECK: fix-it:{{.*}}:{[[@LINE-6]]:14-[[@LINE-6]]:14}:"[1][1]"
32*0a6a1f1dSLionel Sambuc } s;
33*0a6a1f1dSLionel Sambuc
34*0a6a1f1dSLionel Sambuc #ifndef FIXIT
test2()35*0a6a1f1dSLionel Sambuc void test2() {
36*0a6a1f1dSLionel Sambuc int [][][];
37*0a6a1f1dSLionel Sambuc // expected-error@-1{{expected identifier or '('}}
38*0a6a1f1dSLionel Sambuc // CHECK: {{^}} int [][][];
39*0a6a1f1dSLionel Sambuc // CHECK: {{^}} ^
40*0a6a1f1dSLionel Sambuc // CHECK-NOT: fix-it
41*0a6a1f1dSLionel Sambuc struct T {
42*0a6a1f1dSLionel Sambuc int [];
43*0a6a1f1dSLionel Sambuc // expected-error@-1{{expected member name or ';' after declaration specifiers}}
44*0a6a1f1dSLionel Sambuc // CHECK: {{^}} int [];
45*0a6a1f1dSLionel Sambuc // CHECK: {{^}} ~~~ ^
46*0a6a1f1dSLionel Sambuc // CHECK-NOT: fix-it
47*0a6a1f1dSLionel Sambuc };
48*0a6a1f1dSLionel Sambuc }
49*0a6a1f1dSLionel Sambuc
test3()50*0a6a1f1dSLionel Sambuc void test3() {
51*0a6a1f1dSLionel Sambuc int [5] *;
52*0a6a1f1dSLionel Sambuc // expected-error@-1{{expected identifier or '('}}
53*0a6a1f1dSLionel Sambuc // CHECK: {{^}} int [5] *;
54*0a6a1f1dSLionel Sambuc // CHECK: {{^}} ^
55*0a6a1f1dSLionel Sambuc // CHECK-NOT: fix-it
56*0a6a1f1dSLionel Sambuc // expected-error@-5{{brackets go after the identifier}}
57*0a6a1f1dSLionel Sambuc // CHECK: {{^}} int [5] *;
58*0a6a1f1dSLionel Sambuc // CHECK: {{^}} ~~~~ ^
59*0a6a1f1dSLionel Sambuc // CHECK: {{^}} ()[5]
60*0a6a1f1dSLionel Sambuc // CHECK: fix-it:{{.*}}:{[[@LINE-9]]:7-[[@LINE-9]]:11}:""
61*0a6a1f1dSLionel Sambuc // CHECK: fix-it:{{.*}}:{[[@LINE-10]]:11-[[@LINE-10]]:11}:"("
62*0a6a1f1dSLionel Sambuc // CHECK: fix-it:{{.*}}:{[[@LINE-11]]:12-[[@LINE-11]]:12}:")[5]"
63*0a6a1f1dSLionel Sambuc
64*0a6a1f1dSLionel Sambuc int [5] * a;
65*0a6a1f1dSLionel Sambuc // expected-error@-1{{brackets go after the identifier}}
66*0a6a1f1dSLionel Sambuc // CHECK: {{^}} int [5] * a;
67*0a6a1f1dSLionel Sambuc // CHECK: {{^}} ~~~~ ^
68*0a6a1f1dSLionel Sambuc // CHECK: {{^}} ( )[5]
69*0a6a1f1dSLionel Sambuc // CHECK: fix-it:{{.*}}:{[[@LINE-5]]:7-[[@LINE-5]]:11}:""
70*0a6a1f1dSLionel Sambuc // CHECK: fix-it:{{.*}}:{[[@LINE-6]]:11-[[@LINE-6]]:11}:"("
71*0a6a1f1dSLionel Sambuc // CHECK: fix-it:{{.*}}:{[[@LINE-7]]:14-[[@LINE-7]]:14}:")[5]"
72*0a6a1f1dSLionel Sambuc
73*0a6a1f1dSLionel Sambuc int *b[5] = a; // expected-error{{}} a should not be corrected to type b
74*0a6a1f1dSLionel Sambuc
75*0a6a1f1dSLionel Sambuc int (*c)[5] = a; // a should be the same type as c
76*0a6a1f1dSLionel Sambuc }
77*0a6a1f1dSLionel Sambuc #endif
78*0a6a1f1dSLionel Sambuc
79*0a6a1f1dSLionel Sambuc // CHECK: 8 errors generated.
80