| 1 |
// https://bugzilla.gdcproject.org/show_bug.cgi?id=191 |
| 2 |
// { dg-do run } |
| 3 |
// { dg-skip-if "needs gcc/config.d" { ! d_runtime } } |
| 4 |
|
| 5 |
class C191 |
| 6 |
{ |
| 7 |
int count = 0; |
| 8 |
|
| 9 |
void testA() |
| 10 |
{ |
| 11 |
class Inner |
| 12 |
{ |
| 13 |
void test() |
| 14 |
{ |
| 15 |
void localFunction() |
| 16 |
{ |
| 17 |
if (++count != 5) |
| 18 |
testA(); |
| 19 |
} |
| 20 |
localFunction(); |
| 21 |
} |
| 22 |
} |
| 23 |
scope ic = new Inner(); |
| 24 |
ic.test(); |
| 25 |
} |
| 26 |
|
| 27 |
void testB() |
| 28 |
{ |
| 29 |
class Inner |
| 30 |
{ |
| 31 |
void test() |
| 32 |
{ |
| 33 |
void localFunction() |
| 34 |
{ |
| 35 |
void anotherLocalFunction() |
| 36 |
{ |
| 37 |
if (++count != 10) |
| 38 |
testB(); |
| 39 |
} |
| 40 |
anotherLocalFunction(); |
| 41 |
} |
| 42 |
localFunction(); |
| 43 |
} |
| 44 |
} |
| 45 |
scope ic = new Inner(); |
| 46 |
ic.test(); |
| 47 |
} |
| 48 |
|
| 49 |
void testC() |
| 50 |
{ |
| 51 |
class Inner |
| 52 |
{ |
| 53 |
int a = 1; |
| 54 |
|
| 55 |
void test() |
| 56 |
{ |
| 57 |
void localFunction() |
| 58 |
{ |
| 59 |
count += a; |
| 60 |
if (count != 15) |
| 61 |
testC(); |
| 62 |
assert(a == 1); |
| 63 |
} |
| 64 |
localFunction(); |
| 65 |
} |
| 66 |
} |
| 67 |
scope ic = new Inner(); |
| 68 |
ic.test(); |
| 69 |
} |
| 70 |
|
| 71 |
void testD() |
| 72 |
{ |
| 73 |
class Inner |
| 74 |
{ |
| 75 |
void test() |
| 76 |
{ |
| 77 |
int a = 1; |
| 78 |
|
| 79 |
void localFunction() |
| 80 |
{ |
| 81 |
count += a; |
| 82 |
if (count != 20) |
| 83 |
testD(); |
| 84 |
assert(a == 1); |
| 85 |
} |
| 86 |
localFunction(); |
| 87 |
} |
| 88 |
} |
| 89 |
scope ic = new Inner(); |
| 90 |
ic.test(); |
| 91 |
} |
| 92 |
|
| 93 |
void testE() |
| 94 |
{ |
| 95 |
class Inner |
| 96 |
{ |
| 97 |
int a = 1; |
| 98 |
|
| 99 |
void test() |
| 100 |
{ |
| 101 |
void localFunction() |
| 102 |
{ |
| 103 |
void anotherLocalFunction() |
| 104 |
{ |
| 105 |
count += a; |
| 106 |
if (count != 25) |
| 107 |
testE(); |
| 108 |
assert(a == 1); |
| 109 |
} |
| 110 |
|
| 111 |
anotherLocalFunction(); |
| 112 |
} |
| 113 |
|
| 114 |
localFunction(); |
| 115 |
} |
| 116 |
} |
| 117 |
scope ic = new Inner(); |
| 118 |
ic.test(); |
| 119 |
} |
| 120 |
|
| 121 |
void testF() |
| 122 |
{ |
| 123 |
class Inner |
| 124 |
{ |
| 125 |
void test() |
| 126 |
{ |
| 127 |
int a = 1; |
| 128 |
|
| 129 |
void localFunction() |
| 130 |
{ |
| 131 |
void anotherLocalFunction() |
| 132 |
{ |
| 133 |
count += a; |
| 134 |
if (count != 30) |
| 135 |
testF(); |
| 136 |
assert(a == 1); |
| 137 |
} |
| 138 |
|
| 139 |
anotherLocalFunction(); |
| 140 |
} |
| 141 |
|
| 142 |
localFunction(); |
| 143 |
} |
| 144 |
} |
| 145 |
scope ic = new Inner(); |
| 146 |
ic.test(); |
| 147 |
} |
| 148 |
|
| 149 |
void testG() |
| 150 |
{ |
| 151 |
class Inner |
| 152 |
{ |
| 153 |
void test() |
| 154 |
{ |
| 155 |
void localFunction() |
| 156 |
{ |
| 157 |
int a = 1; |
| 158 |
|
| 159 |
void anotherLocalFunction() |
| 160 |
{ |
| 161 |
count += a; |
| 162 |
if (count != 35) |
| 163 |
testG(); |
| 164 |
assert(a == 1); |
| 165 |
} |
| 166 |
|
| 167 |
anotherLocalFunction(); |
| 168 |
} |
| 169 |
|
| 170 |
localFunction(); |
| 171 |
} |
| 172 |
} |
| 173 |
scope ic = new Inner(); |
| 174 |
ic.test(); |
| 175 |
} |
| 176 |
} |
| 177 |
|
| 178 |
void main() |
| 179 |
{ |
| 180 |
scope oc = new C191(); |
| 181 |
oc.testA(); |
| 182 |
assert(oc.count == 5); |
| 183 |
|
| 184 |
oc.testB(); |
| 185 |
assert(oc.count == 10); |
| 186 |
|
| 187 |
oc.testC(); |
| 188 |
assert(oc.count == 15); |
| 189 |
|
| 190 |
oc.testD(); |
| 191 |
assert(oc.count == 20); |
| 192 |
|
| 193 |
oc.testE(); |
| 194 |
assert(oc.count == 25); |
| 195 |
|
| 196 |
oc.testF(); |
| 197 |
assert(oc.count == 30); |
| 198 |
|
| 199 |
oc.testG(); |
| 200 |
assert(oc.count == 35); |
| 201 |
} |