1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 // RUN: not %clang_cc1 -fixit %t -x c++ -DFIXIT
4 // RUN: %clang_cc1 -fsyntax-only %t -x c++ -DFIXIT
5 // RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -fno-diagnostics-show-line-numbers %s 2>&1 | FileCheck %s -strict-whitespace
9 int []b
= {0,1,4,9,16};
10 // expected-error@-1{{brackets are not allowed here; to declare an array, place the brackets after the name}}
11 // CHECK: {{^}} int []b = {0,1,4,9,16};
14 // CHECK: fix-it:{{.*}}:{[[@LINE-5]]:7-[[@LINE-5]]:9}:""
15 // CHECK: fix-it:{{.*}}:{[[@LINE-6]]:10-[[@LINE-6]]:10}:"[]"
18 int d
= b
[0]; // No undeclared identifier error here.
21 int *f
= b
; // No undeclared identifier error here.
24 // expected-error@-1{{brackets are not allowed here; to declare an array, place the brackets after the name}}
25 // CHECK: {{^}} int[1] g[2];
28 // CHECK: fix-it:{{.*}}:{[[@LINE-5]]:6-[[@LINE-5]]:9}:""
29 // CHECK: fix-it:{{.*}}:{[[@LINE-6]]:14-[[@LINE-6]]:14}:"[1]"
34 // expected-error@-1{{brackets are not allowed here; to declare an array, place the brackets after the name}}
35 // CHECK: {{^}} int [3] (*a) = 0;
38 // CHECK: fix-it:{{.*}}:{[[@LINE-5]]:7-[[@LINE-5]]:11}:""
39 // CHECK: fix-it:{{.*}}:{[[@LINE-6]]:15-[[@LINE-6]]:15}:"[3]"
42 // Make sure a is corrected to be like type y, instead of like type z.
44 int (*c
[3]) = a
; // expected-error{{}}
50 // expected-error@-1{{brackets are not allowed here; to declare an array, place the brackets after the name}}
51 // CHECK: {{^}} static int [1][1]x;
52 // CHECK: {{^}} ~~~~~~ ^
53 // CHECK: {{^}} [1][1]
54 // CHECK: fix-it:{{.*}}:{[[@LINE-5]]:14-[[@LINE-5]]:20}:""
55 // CHECK: fix-it:{{.*}}:{[[@LINE-6]]:21-[[@LINE-6]]:21}:"[1][1]"
58 int [1][1]A::x
= { {42} };
59 // expected-error@-1{{brackets are not allowed here; to declare an array, place the brackets after the name}}
60 // CHECK: {{^}}int [1][1]A::x = { {42} };
61 // CHECK: {{^}} ~~~~~~ ^
62 // CHECK: {{^}} [1][1]
63 // CHECK: fix-it:{{.*}}:{[[@LINE-5]]:5-[[@LINE-5]]:11}:""
64 // CHECK: fix-it:{{.*}}:{[[@LINE-6]]:15-[[@LINE-6]]:15}:"[1][1]"
66 struct B
{ static int (*x
)[5]; };
68 // expected-error@-1{{brackets are not allowed here; to declare an array, place the brackets after the name}}
69 // CHECK: {{^}}int [5] *B::x = 0;
71 // CHECK: {{^}} ( )[5]
72 // CHECK: fix-it:{{.*}}:{[[@LINE-5]]:5-[[@LINE-5]]:9}:""
73 // CHECK: fix-it:{{.*}}:{[[@LINE-6]]:9-[[@LINE-6]]:9}:"("
74 // CHECK: fix-it:{{.*}}:{[[@LINE-7]]:14-[[@LINE-7]]:14}:")[5]"
78 // expected-error@-1{{brackets are not allowed here; to declare an array, place the brackets after the name}}
79 // CHECK: {{^}} int [3] *a;
81 // CHECK: {{^}} ( )[3]
82 // CHECK: fix-it:{{.*}}:{[[@LINE-5]]:7-[[@LINE-5]]:11}:""
83 // CHECK: fix-it:{{.*}}:{[[@LINE-6]]:11-[[@LINE-6]]:11}:"("
84 // CHECK: fix-it:{{.*}}:{[[@LINE-7]]:13-[[@LINE-7]]:13}:")[3]"
86 int (*b
)[3] = a
; // no error
91 // expected-error@-1{{brackets are not allowed here; to declare an array, place the brackets after the name}}
92 // CHECK: {{^}} int [2] a;
95 // CHECK: fix-it:{{.*}}:{[[@LINE-5]]:7-[[@LINE-5]]:11}:""
96 // CHECK: fix-it:{{.*}}:{[[@LINE-6]]:12-[[@LINE-6]]:12}:"[2]"
99 // expected-error@-1{{brackets are not allowed here; to declare an array, place the brackets after the name}}
100 // CHECK: {{^}} int [2] &b = a;
101 // CHECK: {{^}} ~~~ ^
102 // CHECK: {{^}} ( )[2]
103 // CHECK: fix-it:{{.*}}:{[[@LINE-5]]:7-[[@LINE-5]]:11}:""
104 // CHECK: fix-it:{{.*}}:{[[@LINE-6]]:11-[[@LINE-6]]:11}:"("
105 // CHECK: fix-it:{{.*}}:{[[@LINE-7]]:13-[[@LINE-7]]:13}:")[2]"
112 // expected-error@-1{{expected unqualified-id}}
113 // CHECK: {{^}}int [][][];
118 // expected-error@-1{{expected member name or ';' after declaration specifiers}}
119 // CHECK: {{^}} int [];
120 // CHECK: {{^}} ~~~ ^
130 int [3] ::test6::A::arr
= {1,2,3};
131 // expected-error@-1{{brackets are not allowed here; to declare an array, place the brackets after the name}}
132 // CHECK: {{^}}int [3] ::test6::A::arr = {1,2,3};
133 // CHECK: {{^}} ~~~ ^
135 // CHECK: fix-it:{{.*}}:{[[@LINE-5]]:5-[[@LINE-5]]:9}:""
136 // CHECK: fix-it:{{.*}}:{[[@LINE-6]]:24-[[@LINE-6]]:24}:"[3]"
144 // expected-error@-1{{brackets are not allowed here; to declare an array, place the brackets after the name}}
145 // CHECK: {{^}} int [3] A::*a;
146 // CHECK: {{^}} ~~~ ^
147 // CHECK: {{^}} ( )[3]
148 // CHECK: fix-it:{{.*}}:{[[@LINE-5]]:7-[[@LINE-5]]:11}:""
149 // CHECK: fix-it:{{.*}}:{[[@LINE-6]]:11-[[@LINE-6]]:11}:"("
150 // CHECK: fix-it:{{.*}}:{[[@LINE-7]]:16-[[@LINE-7]]:16}:")[3]"
156 static const char f
[];
158 const char[] A::f
= "f";
159 // expected-error@-1{{brackets are not allowed here; to declare an array, place the brackets after the name}}
161 // CHECK: 15 errors generated.