]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gdc.test/fail_compilation/ice17831.d
Add D front-end, libphobos library, and D2 testsuite.
[thirdparty/gcc.git] / gcc / testsuite / gdc.test / fail_compilation / ice17831.d
1 // REQUIRED_ARGS: -d
2 /*
3 TEST_OUTPUT:
4 ---
5 fail_compilation/ice17831.d(19): Error: case variable `i` declared at fail_compilation/ice17831.d(17) cannot be declared in switch body
6 fail_compilation/ice17831.d(33): Error: case variable `i` declared at fail_compilation/ice17831.d(31) cannot be declared in switch body
7 fail_compilation/ice17831.d(48): Error: case variable `i` declared at fail_compilation/ice17831.d(45) cannot be declared in switch body
8 fail_compilation/ice17831.d(61): Error: case variable `i` declared at fail_compilation/ice17831.d(60) cannot be declared in switch body
9 fail_compilation/ice17831.d(73): Error: case variable `i` declared at fail_compilation/ice17831.d(72) cannot be declared in switch body
10 ---
11 */
12
13 void test17831a()
14 {
15 switch (0)
16 {
17 foreach (i; 0 .. 5)
18 {
19 case i:
20 break;
21 }
22 default:
23 break;
24 }
25 }
26
27 void test17831b()
28 {
29 switch (0)
30 {
31 for (int i = 0; i < 5; i++)
32 {
33 case i:
34 break;
35 }
36 default:
37 break;
38 }
39 }
40
41 void test17831c()
42 {
43 switch (0)
44 {
45 int i = 0;
46 while (i++ < 5)
47 {
48 case i:
49 break;
50 }
51 default:
52 break;
53 }
54 }
55
56 void test17831d()
57 {
58 switch (0)
59 {
60 int i = 0;
61 case i:
62 break;
63 default:
64 break;
65 }
66 }
67
68 void test17831e()
69 {
70 switch (0)
71 {
72 static int i = 0;
73 case i:
74 break;
75 default:
76 break;
77 }
78 }