]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gdc.test/fail_compilation/ice9806.d
d: Import dmd b8384668f, druntime e6caaab9, phobos 5ab9ad256 (v2.098.0-beta.1)
[thirdparty/gcc.git] / gcc / testsuite / gdc.test / fail_compilation / ice9806.d
CommitLineData
b4c522fa
IB
1/*
2TEST_OUTPUT:
3---
4fail_compilation/ice9806.d(12): Error: undefined identifier `undefined_expr`
5fee5ec3 5fail_compilation/ice9806.d(17): Error: template instance `ice9806.S1!()` error instantiating
b4c522fa 6fail_compilation/ice9806.d(13): Error: undefined identifier `undefined_expr`
5fee5ec3 7fail_compilation/ice9806.d(19): Error: template instance `ice9806.C1!()` error instantiating
b4c522fa 8fail_compilation/ice9806.d(14): Error: undefined identifier `undefined_expr`
5fee5ec3 9fail_compilation/ice9806.d(21): Error: template instance `ice9806.I1!()` error instantiating
b4c522fa
IB
10---
11*/
12struct S1() { enum x = undefined_expr; }
13class C1() { enum x = undefined_expr; }
14class I1() { enum x = undefined_expr; }
15void test1() {
16 static assert(!is(typeof(S1!().x)));
17 auto sx = S1!().x;
18 static assert(!is(typeof(C1!().x)));
19 auto cx = C1!().x;
20 static assert(!is(typeof(I1!().x)));
21 auto ix = I1!().x;
22}
23
24// --------
25/*
26TEST_OUTPUT:
27---
28fail_compilation/ice9806.d(36): Error: undefined identifier `undefined_expr`
5fee5ec3 29fail_compilation/ice9806.d(44): Error: template instance `ice9806.S2!()` error instantiating
b4c522fa 30fail_compilation/ice9806.d(37): Error: undefined identifier `undefined_expr`
5fee5ec3 31fail_compilation/ice9806.d(46): Error: template instance `ice9806.C2!()` error instantiating
b4c522fa 32fail_compilation/ice9806.d(38): Error: undefined identifier `undefined_expr`
5fee5ec3 33fail_compilation/ice9806.d(48): Error: template instance `ice9806.I2!()` error instantiating
b4c522fa
IB
34---
35*/
36int foo2()() { return undefined_expr; }
37int bar2()() { return undefined_expr; }
38int baz2()() { return undefined_expr; }
39struct S2() { enum x = foo2(); }
40class C2() { enum x = bar2(); }
41class I2() { enum x = baz2(); }
42void test2() {
43 static assert(!is(typeof(S2!().x)));
44 auto sx = S2!().x;
45 static assert(!is(typeof(C2!().x)));
46 auto cx = C2!().x;
47 static assert(!is(typeof(I2!().x)));
48 auto ix = I2!().x;
49}