]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gdc.test/fail_compilation/fail9537.d
Add D front-end, libphobos library, and D2 testsuite.
[thirdparty/gcc.git] / gcc / testsuite / gdc.test / fail_compilation / fail9537.d
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/fail9537.d(26): Error: foo(tuple(1, 2)) is not an lvalue
5 ---
6 */
7
8 struct Tuple(T...)
9 {
10 T field;
11 alias field this;
12 }
13
14 Tuple!T tuple(T...)(T args)
15 {
16 return Tuple!T(args);
17 }
18
19 auto ref foo(T)(auto ref T t)
20 {
21 return t[0]; // t[0] is deduced to non-ref
22 }
23
24 void main()
25 {
26 int* p = &foo(tuple(1, 2));
27 }