| 1 |
/* |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/ice17831.d(23): Error: `case` variables have to be `const` or `immutable` |
| 5 |
fail_compilation/ice17831.d(23): Error: `case` variable `i` declared at fail_compilation/ice17831.d(21) cannot be declared in `switch` body |
| 6 |
fail_compilation/ice17831.d(37): Error: `case` variables have to be `const` or `immutable` |
| 7 |
fail_compilation/ice17831.d(37): Error: `case` variable `i` declared at fail_compilation/ice17831.d(35) cannot be declared in `switch` body |
| 8 |
fail_compilation/ice17831.d(52): Error: `case` variables have to be `const` or `immutable` |
| 9 |
fail_compilation/ice17831.d(52): Error: `case` variable `i` declared at fail_compilation/ice17831.d(49) cannot be declared in `switch` body |
| 10 |
fail_compilation/ice17831.d(65): Error: `case` variables have to be `const` or `immutable` |
| 11 |
fail_compilation/ice17831.d(65): Error: `case` variable `i` declared at fail_compilation/ice17831.d(64) cannot be declared in `switch` body |
| 12 |
fail_compilation/ice17831.d(77): Error: `case` variables have to be `const` or `immutable` |
| 13 |
fail_compilation/ice17831.d(77): Error: `case` variable `i` declared at fail_compilation/ice17831.d(76) cannot be declared in `switch` body |
| 14 |
--- |
| 15 |
*/ |
| 16 |
|
| 17 |
void test17831a() |
| 18 |
{ |
| 19 |
switch (0) |
| 20 |
{ |
| 21 |
foreach (i; 0 .. 5) |
| 22 |
{ |
| 23 |
case i: |
| 24 |
break; |
| 25 |
} |
| 26 |
default: |
| 27 |
break; |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
void test17831b() |
| 32 |
{ |
| 33 |
switch (0) |
| 34 |
{ |
| 35 |
for (int i = 0; i < 5; i++) |
| 36 |
{ |
| 37 |
case i: |
| 38 |
break; |
| 39 |
} |
| 40 |
default: |
| 41 |
break; |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
void test17831c() |
| 46 |
{ |
| 47 |
switch (0) |
| 48 |
{ |
| 49 |
int i = 0; |
| 50 |
while (i++ < 5) |
| 51 |
{ |
| 52 |
case i: |
| 53 |
break; |
| 54 |
} |
| 55 |
default: |
| 56 |
break; |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
void test17831d() |
| 61 |
{ |
| 62 |
switch (0) |
| 63 |
{ |
| 64 |
int i = 0; |
| 65 |
case i: |
| 66 |
break; |
| 67 |
default: |
| 68 |
break; |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
void test17831e() |
| 73 |
{ |
| 74 |
switch (0) |
| 75 |
{ |
| 76 |
static int i = 0; |
| 77 |
case i: |
| 78 |
break; |
| 79 |
default: |
| 80 |
break; |
| 81 |
} |
| 82 |
} |