]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gdc.test/compilable/mixintype2.d
d: Import dmd b8384668f, druntime e6caaab9, phobos 5ab9ad256 (v2.098.0-beta.1)
[thirdparty/gcc.git] / gcc / testsuite / gdc.test / compilable / mixintype2.d
CommitLineData
5a0aa603
IB
1
2alias fun = mixin("(){}");
3
4void test1()
5{
6 int x = 1;
7 static immutable c = 2;
8
9 fun();
10 foo!(mixin("int"))();
11 foo!(mixin("long*"))();
12 foo!(mixin("ST!(int, S.T)"))();
13 foo!(mixin(ST!(int, S.T)))();
14
15 int[mixin("string")] a1;
16 int[mixin("5")] a2;
17 int[mixin("c")] a3;
18 int[] v1 = new int[mixin("3")];
19 auto v2 = new int[mixin("x")];
20
21 mixin(q{__traits(getMember, S, "T")}) ftv;
22
23 alias T = int*;
24 static assert(__traits(compiles, mixin("int")));
25 static assert(__traits(compiles, mixin(q{int[mixin("string")]})));
26 static assert(__traits(compiles, mixin(q{int[mixin("2")]})));
27 static assert(__traits(compiles, mixin(T)));
28 static assert(__traits(compiles, mixin("int*")));
29 static assert(__traits(compiles, mixin(typeof(0))));
30}
31
32struct S { alias T = float*; }
33
34struct ST(X,Y) {}
35
36void foo(alias t)() {}
37
38/**************************************************/
39// https://issues.dlang.org/show_bug.cgi?id=21074
40
41alias Byte = ubyte;
42alias Byte2(A) = ubyte;
43alias T0 = mixin(q{const(Byte)})*;
44alias T1 = mixin(q{const(Byte[1])})*;
45alias T2 = mixin(q{const(Byte2!int)})*;
46alias T3 = mixin(q{const(mixin(Byte2!int))})*;
47alias T4 = mixin(q{const(mixin("__traits(getMember, S, \"T\")"))})*;
48alias T5 = const(mixin(q{Byte}))*;
49alias T6 = const(mixin(q{immutable(Byte)}))*;
50alias T7 = const(mixin(q{shared(Byte)}))*;
51alias T8 = const(mixin(q{Byte*}));
52
53// the following tests now work
54static assert(is(T0 == const(ubyte)*));
55static assert(is(T1 == const(ubyte[1])*));
56static assert(is(T2 == const(ubyte)*));
57static assert(is(T3 == const(ubyte)*));
58static assert(is(T4 == const(float*)*));
59static assert(is(T5 == const(ubyte)*));
60static assert(is(T6 == immutable(ubyte)*));
61static assert(is(T7 == const(shared(ubyte))*));
62static assert(is(T8 == const(ubyte*)));
63
64// this doesn't work but I'll file a new issue
65/*
66alias T8 = mixin(q{immutable(__traits(getMember, S, "T"))})*;
67static assert(is(T8 == immutable(float*)*));
68*/