d: Merge upstream dmd 568496d5b, druntime 178c44ff, phobos 574bf883b.
[official-gcc.git] / gcc / testsuite / gdc.test / compilable / test1537.d
blob0878b97230ce33c2c5bd961606ac11737f89249b
1 // https://issues.dlang.org/show_bug.cgi?id=1537
3 void foo(char[] s)
5 int x = -1;
7 while (s.length)
9 char c = s[0];
11 if (c == '}')
12 break;
14 assert (c >= '0' && c <= '9', s[0..$]);
16 if (x == -1)
17 x = 0;
21 /**************************************/
23 enum bug4732 = 42;
24 static assert( __traits(identifier, bug4732) == "bug4732");
26 /**************************************/
28 template Compileable(int z) { bool OK=true;}
30 int bug5245a(U)()
32 { enum T { a = 5 } T v; }
33 { enum T { a = 6 } T w; }
34 return 91;
37 int bug5245b(U)()
39 { struct T { int a = 2; } T v; }
40 { union T { int a = 3; } T w; }
41 return 91;
44 int bug5245c(U)()
46 { struct T { int a = 2; } T v; }
47 { class T { int a = 3; } T w; }
48 return 91;
51 int bug5245d(U)()
53 { enum T { a = 3 } T w; }
54 { struct T { int a = 2; } T v; }
55 return 91;
59 static assert(is(typeof(Compileable!(bug5245a!(int)()).OK)));
60 static assert(is(typeof(Compileable!(bug5245b!(int)()).OK)));
61 static assert(is(typeof(Compileable!(bug5245c!(int)()).OK)));
62 static assert(is(typeof(Compileable!(bug5245d!(int)()).OK)));
64 /**************************************/
66 class Bug5349(T) // segfault D2.051
68 int x;
69 static int g()
71 class B
73 int inner()
75 return x; // should not compile
78 return (new B).inner();
80 int y = g();
83 static assert(!is(typeof(Bug5349!(int))));
85 /**************************************/
87 class Bug4033 {}
89 class Template4033(T) {
90 static assert(is(T : Bug4033));
93 alias Template4033!(Z4033) Bla;
95 class Z4033 : Bug4033 { }
97 /**************************************/
99 struct Bug4322 {
100 int[1] a = void;
103 void bug4322() {
104 Bug4322 f = Bug4322();
105 Bug4322 g = Bug4322.init;