6 fail_compilation/fail_arrayop2.d(12): Error: array operation `[1, 2, 3] - [1, 2, 3]` without destination memory not allowed
7 fail_compilation/fail_arrayop2.d(15): Error: invalid array operation `"a" - "b"` (possible missing [])
10 void test2603() // Issue 2603 - ICE(cgcs.c) on subtracting string literals
12 auto c1 = [1,2,3] - [1,2,3];
14 // this variation is wrong code on D2, ICE ..\ztc\cgcs.c 358 on D1.
15 string c2 = "a" - "b";
21 fail_compilation/fail_arrayop2.d(37): Error: array operation `-a[]` without destination memory not allowed (possible missing [])
22 fail_compilation/fail_arrayop2.d(38): Error: array operation `~a[]` without destination memory not allowed (possible missing [])
23 fail_compilation/fail_arrayop2.d(40): Error: array operation `a[] + a[]` without destination memory not allowed (possible missing [])
24 fail_compilation/fail_arrayop2.d(41): Error: array operation `a[] - a[]` without destination memory not allowed (possible missing [])
25 fail_compilation/fail_arrayop2.d(42): Error: array operation `a[] * a[]` without destination memory not allowed (possible missing [])
26 fail_compilation/fail_arrayop2.d(43): Error: array operation `a[] / a[]` without destination memory not allowed (possible missing [])
27 fail_compilation/fail_arrayop2.d(44): Error: array operation `a[] % a[]` without destination memory not allowed (possible missing [])
28 fail_compilation/fail_arrayop2.d(45): Error: array operation `a[] ^ a[]` without destination memory not allowed (possible missing [])
29 fail_compilation/fail_arrayop2.d(46): Error: array operation `a[] & a[]` without destination memory not allowed (possible missing [])
30 fail_compilation/fail_arrayop2.d(47): Error: array operation `a[] | a[]` without destination memory not allowed (possible missing [])
31 fail_compilation/fail_arrayop2.d(48): Error: array operation `a[] ^^ a[]` without destination memory not allowed (possible missing [])
54 fail_compilation/fail_arrayop2.d(74): Error: array operation `a[] + a[]` without destination memory not allowed
55 fail_compilation/fail_arrayop2.d(75): Error: array operation `a[] - a[]` without destination memory not allowed
56 fail_compilation/fail_arrayop2.d(76): Error: array operation `a[] * a[]` without destination memory not allowed
57 fail_compilation/fail_arrayop2.d(77): Error: array operation `a[] / a[]` without destination memory not allowed
58 fail_compilation/fail_arrayop2.d(78): Error: array operation `a[] % a[]` without destination memory not allowed
59 fail_compilation/fail_arrayop2.d(79): Error: array operation `a[] ^ a[]` without destination memory not allowed
60 fail_compilation/fail_arrayop2.d(80): Error: array operation `a[] & a[]` without destination memory not allowed
61 fail_compilation/fail_arrayop2.d(81): Error: array operation `a[] | a[]` without destination memory not allowed
62 fail_compilation/fail_arrayop2.d(82): Error: array operation `a[] ^^ 10` without destination memory not allowed
63 fail_compilation/fail_arrayop2.d(83): Error: array operation `-a[]` without destination memory not allowed
64 fail_compilation/fail_arrayop2.d(84): Error: array operation `~a[]` without destination memory not allowed
65 fail_compilation/fail_arrayop2.d(89): Error: array operation `[1] + a[]` without destination memory not allowed
66 fail_compilation/fail_arrayop2.d(90): Error: array operation `[1] + a[]` without destination memory not allowed
89 arr1 ~= [1] + a[]; // NG
90 arr2 ~= [1] + a[]; // NG
96 fail_compilation/fail_arrayop2.d(104): Error: array operation `h * y[]` without destination memory not allowed
104 double[2] temp1 = cast(double[2])(h * y[]);
110 fail_compilation/fail_arrayop2.d(117): Error: array operation `-a[]` without destination memory not allowed
111 fail_compilation/fail_arrayop2.d(119): Error: array operation `(-a[])[0..4]` without destination memory not allowed
114 float[] test12769(float[] a)
125 fail_compilation/fail_arrayop2.d(136): Error: array operation `a[] - a[]` without destination memory not allowed
126 fail_compilation/fail_arrayop2.d(138): Error: array operation `a[] - a[]` without destination memory not allowed
127 fail_compilation/fail_arrayop2.d(139): Error: array operation `a[] - a[]` without destination memory not allowed
128 fail_compilation/fail_arrayop2.d(142): Error: array operation `a[] - a[]` without destination memory not allowed
129 fail_compilation/fail_arrayop2.d(144): Error: array operation `a[] - a[]` without destination memory not allowed
136 auto arr = [a[] - a[]][0];
138 auto aa1 = [1 : a[] - a[]];
139 auto aa2 = [a[] - a[] : 1];
141 struct S { int[] a; }
142 auto s = S(a[] - a[]);
144 auto n = int(a[] - a[]);
150 fail_compilation/fail_arrayop2.d(159): Error: array operation `a[] * a[]` without destination memory not allowed
151 fail_compilation/fail_arrayop2.d(160): Error: array operation `(a[] * a[])[0..1]` without destination memory not allowed
152 fail_compilation/fail_arrayop2.d(163): Error: array operation `a[] * a[]` without destination memory not allowed (possible missing [])
153 fail_compilation/fail_arrayop2.d(164): Error: array operation `(a[] * a[])[0..1]` without destination memory not allowed (possible missing [])
159 auto b1 = (a[] * a[])[];
160 auto b2 = (a[] * a[])[0..1];
164 c = (a[] * a[])[0..1];
170 fail_compilation/fail_arrayop2.d(180): Error: array operation `data[segmentId][28..29] & cast(ubyte)(1 << 0)` without destination memory not allowed
180 return !!((data[segmentId][28..29]) & (1 << 0));
187 fail_compilation/fail_arrayop2.d(194): Error: array operation `a[] + 1` without destination memory not allowed
188 fail_compilation/fail_arrayop2.d(194): Error: array operation `a[] * 2` without destination memory not allowed
194 int[] b = (a[] + 1) ~ a[] * 2;
200 fail_compilation/fail_arrayop2.d(245): Error: array operation `[1] * 6` without destination memory not allowed
201 fail_compilation/fail_arrayop2.d(246): Error: array operation `[1] * 6` without destination memory not allowed
202 fail_compilation/fail_arrayop2.d(247): Error: array operation `[1] * 6` without destination memory not allowed
203 fail_compilation/fail_arrayop2.d(252): Error: array operation `[1] * 6` without destination memory not allowed
204 fail_compilation/fail_arrayop2.d(255): Error: array operation `[1] * 6` without destination memory not allowed
205 fail_compilation/fail_arrayop2.d(264): Error: array operation `[1] * 6` without destination memory not allowed
206 fail_compilation/fail_arrayop2.d(267): Error: array operation `[1] * 6` without destination memory not allowed
207 fail_compilation/fail_arrayop2.d(268): Error: array operation `"abc"[] + '\x01'` without destination memory not allowed
208 fail_compilation/fail_arrayop2.d(271): Error: array operation `[1] * 6` without destination memory not allowed
209 fail_compilation/fail_arrayop2.d(274): Error: ([1] * 6)[0..2] is not an lvalue
210 fail_compilation/fail_arrayop2.d(277): Error: can only * a pointer, not a 'int[]'
211 fail_compilation/fail_arrayop2.d(280): Error: [1] * 6 is not an lvalue
212 fail_compilation/fail_arrayop2.d(283): Error: array operation `da[] * 6` without destination memory not allowed
213 fail_compilation/fail_arrayop2.d(286): Error: array operation `da[] * 6` without destination memory not allowed
214 fail_compilation/fail_arrayop2.d(289): Error: [1] * 6 is not an lvalue
215 fail_compilation/fail_arrayop2.d(290): Error: invalid array operation `[1] * 6 -= 1` for element type `int`
216 fail_compilation/fail_arrayop2.d(293): Error: [1] * 6 is not an lvalue
217 fail_compilation/fail_arrayop2.d(294): Error: ([1] * 6)[] is not an lvalue
218 fail_compilation/fail_arrayop2.d(297): Error: invalid array operation `[1] * 6 += 1` for element type `int`
219 fail_compilation/fail_arrayop2.d(298): Error: invalid array operation `[1] * 6 *= 2` for element type `int`
220 fail_compilation/fail_arrayop2.d(299): Error: invalid array operation `[1] * 6 ^^= 3` for element type `int`
221 fail_compilation/fail_arrayop2.d(302): Error: [1] * 6 is not an lvalue
222 fail_compilation/fail_arrayop2.d(303): Error: [1] * 6 is not an lvalue
223 fail_compilation/fail_arrayop2.d(306): Error: '[1] * 6' is not of integral type, it is a int[]
224 fail_compilation/fail_arrayop2.d(307): Error: '[1] * 6' is not of integral type, it is a int[]
225 fail_compilation/fail_arrayop2.d(308): Error: '[1] * 6' is not of integral type, it is a int[]
226 fail_compilation/fail_arrayop2.d(311): Error: array operation `[1] * 6` without destination memory not allowed
227 fail_compilation/fail_arrayop2.d(312): Error: array operation `[1] * 6` without destination memory not allowed
228 fail_compilation/fail_arrayop2.d(315): Error: array operation `[1] * 6` without destination memory not allowed
229 fail_compilation/fail_arrayop2.d(316): Error: array operation `[1] * 6` without destination memory not allowed
230 fail_compilation/fail_arrayop2.d(317): Error: array operation `[1] * 6` without destination memory not allowed
231 fail_compilation/fail_arrayop2.d(320): Error: array operation `[1] * 6` without destination memory not allowed
232 fail_compilation/fail_arrayop2.d(320): Error: array operation `[1] * 6` without destination memory not allowed
233 fail_compilation/fail_arrayop2.d(320): Error: array operation `[1] * 6` without destination memory not allowed
236 // Test all expressions, which can take arrays as their operands but cannot be a part of array operation.
239 struct S { int[] a; }
245 { auto r = [[1] * 6]; } // ArrayLiteralExp
246 { auto r = [[1] * 6 :
247 [1] * 6]; } // AssocArrayLiteralExp
251 // StructLiteralExp.elements <- preFunctionParameters in CallExp
252 { auto r = S([1] * 6); }
254 // NewExp.newargs/arguments <- preFunctionParameters
255 { auto r = new S([1] * 6); }
258 //auto ti = typeid([1] * 6);
259 //auto foo(T)(T t) {}
260 //foo(typeid([1] * 6));
261 //auto a = [typeid([1] * 6)];
264 { auto r = ([1] * 6, 1); }
268 cast(char)1 + "abc"[]);
270 // CallExp.arguments <- preFunctionParameters
273 // AddrExp, if a CT-known length slice can become an TypeSarray lvalue in the future.
274 { auto r = &(([1] * 6)[0..2]); }
276 // PtrExp, *([1] * 6).ptr is also invalid -> show better diagnostic
277 { auto r = *([1] * 6); }
282 // TypeDArray.dotExp, cannot check in ArrayLengthExp.semantic()
283 { auto r = (6 * da[]).length; }
286 { auto x1 = (da[] * 6)[1]; }
305 // Shl, Shr, UshrExp - e1, e2 --> checkIntegralBin
306 { auto r = ([1] * 6) << 1; }
307 { auto r = ([1] * 6) >> 1; }
308 { auto r = ([1] * 6) >>> 1; }
310 // AndAnd, OrOrExp - e1, e2
311 { auto r = sa[0..5] && [1] * 6; }
312 { auto r = sa[0..5] || [1] * 6; }
314 // Cmp, Equal, IdentityExp - e1, e2
315 { auto r = sa[0..5] <= [1] * 6; }
316 { auto r = sa[0..5] == [1] * 6; }
317 { auto r = sa[0..5] is [1] * 6; }
319 // CondExp - econd, e1, e2
320 { auto r = [1] * 6 ? [1] * 6 : [1] * 6; }
326 fail_compilation/fail_arrayop2.d(341): Error: array operation `[1] * 6` without destination memory not allowed
327 fail_compilation/fail_arrayop2.d(344): Error: array operation `[1] * 6` without destination memory not allowed
328 fail_compilation/fail_arrayop2.d(347): Error: array operation `[1] * 6` without destination memory not allowed
329 fail_compilation/fail_arrayop2.d(348): Error: array operation `[1] * 6` without destination memory not allowed
330 fail_compilation/fail_arrayop2.d(349): Error: array operation `[1] * 6` without destination memory not allowed
331 fail_compilation/fail_arrayop2.d(352): Error: array operation `[1] * 6` without destination memory not allowed
332 fail_compilation/fail_arrayop2.d(355): Error: array operation `[1] * 6` without destination memory not allowed
333 fail_compilation/fail_arrayop2.d(358): Error: array operation `"str"[] + cast(immutable(char))1` without destination memory not allowed
334 fail_compilation/fail_arrayop2.d(366): Error: CTFE internal error: non-constant value "uvt"[]
337 // Test all statements, which can take arrays as their operands.
340 // ExpStatement - exp
343 // DoStatement - condition
344 do {} while ([1] * 6);
346 // ForStatement - condition, increment
347 for ([1] * 6; // init == ExpStatement
351 // ForeachStatement - aggr -> lowered to ForStatement
352 foreach (e; [1] * 6) {}
354 // IfStatement condition
357 // SwitchStatement - condition
363 // CaseStatement - exp
366 case "uvt"[] - 1: break;