]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gdc.test/fail_compilation/ice17831.d
d: Import dmd b8384668f, druntime e6caaab9, phobos 5ab9ad256 (v2.098.0-beta.1)
[thirdparty/gcc.git] / gcc / testsuite / gdc.test / fail_compilation / ice17831.d
CommitLineData
b4c522fa
IB
1/*
2TEST_OUTPUT:
3---
5fee5ec3
IB
4fail_compilation/ice17831.d(23): Error: `case` variables have to be `const` or `immutable`
5fail_compilation/ice17831.d(23): Error: `case` variable `i` declared at fail_compilation/ice17831.d(21) cannot be declared in `switch` body
6fail_compilation/ice17831.d(37): Error: `case` variables have to be `const` or `immutable`
7fail_compilation/ice17831.d(37): Error: `case` variable `i` declared at fail_compilation/ice17831.d(35) cannot be declared in `switch` body
8fail_compilation/ice17831.d(52): Error: `case` variables have to be `const` or `immutable`
9fail_compilation/ice17831.d(52): Error: `case` variable `i` declared at fail_compilation/ice17831.d(49) cannot be declared in `switch` body
10fail_compilation/ice17831.d(65): Error: `case` variables have to be `const` or `immutable`
11fail_compilation/ice17831.d(65): Error: `case` variable `i` declared at fail_compilation/ice17831.d(64) cannot be declared in `switch` body
12fail_compilation/ice17831.d(77): Error: `case` variables have to be `const` or `immutable`
13fail_compilation/ice17831.d(77): Error: `case` variable `i` declared at fail_compilation/ice17831.d(76) cannot be declared in `switch` body
b4c522fa
IB
14---
15 */
16
17void 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
31void 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
45void 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
60void test17831d()
61{
62 switch (0)
63 {
64 int i = 0;
65 case i:
66 break;
67 default:
68 break;
69 }
70}
71
72void test17831e()
73{
74 switch (0)
75 {
76 static int i = 0;
77 case i:
78 break;
79 default:
80 break;
81 }
82}