Deprecate the ARM simulator
[official-gcc.git] / gcc / testsuite / gdc.test / fail_compilation / test8556.d
blob75c5c593eead7ecb0eed7ce4b8eee1f927c31c12
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/test8556.d(24): Error: template instance `test8556.Grab!(Circle!(uint[]))` does not match template declaration `Grab(Range)`
5 with `Range = Circle!(uint[])`
6 must satisfy the following constraint:
7 ` !isSliceable!Range`
8 fail_compilation/test8556.d(55): Error: template instance `test8556.grab!(Circle!(uint[]))` error instantiating
9 ---
12 extern(C) int printf(const char*, ...);
14 template isSliceable(R)
16 enum bool isSliceable = is(typeof( R.init[1 .. 2] ));
19 struct Grab(Range) if (!isSliceable!Range)
21 public Range source;
24 Grab!R grab(R)(R input)
26 return Grab!R(input);
29 // 3. evaluate isSliceable in template constraint
30 auto grabExactly(R)(R range) if (!isSliceable!R) { return 0; }
31 auto grabExactly(R)(R range) if ( isSliceable!R) { return 0; }
33 struct Circle(Range)
35 // 2. auto return opSlice
36 auto opSlice(size_t i, size_t j)
38 //pragma(msg, typeof(opSlice)); // prints "fwdref err" with B, but doesn't with A
40 printf("%d %d\n", cast(int)i, cast(int)j);
41 assert(j >= i);
43 // 1. grabExactly curcular refers this opSlice.
44 return grabExactly(typeof(this)()); // broken execution with A
48 Circle!R circle(R)()
50 return Circle!R();
53 void main()
55 auto t = grab(circle!(uint[])());
57 auto cx = circle!(uint[])();
58 auto slice = cx[23 .. 33];