MATCH: Improve `A CMP 0 ? A : -A` set of patterns to use bitwise_equal_p.
[official-gcc.git] / gcc / testsuite / gdc.test / fail_compilation / goto2.d
blob72e8bcb6d07061952d652b29307b710f66ee52a7
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/goto2.d(1024): Error: case cannot be in different `try` block level from `switch`
5 fail_compilation/goto2.d(1026): Error: default cannot be in different `try` block level from `switch`
6 fail_compilation/goto2.d(1003): Error: cannot `goto` into `try` block
7 ---
8 */
11 void foo();
12 void bar();
14 #line 1000
16 void test1()
18 goto L1;
19 try
21 foo();
22 L1:
23 { }
25 finally
27 bar();
30 /********************************/
32 int i;
33 switch (i)
35 case 1:
36 try
38 foo();
39 case 2:
40 { }
41 default:
42 { }
44 finally
46 bar();
48 break;
52 /**************************************************
53 https://issues.dlang.org/show_bug.cgi?id=11540
54 goto label + try-catch-finally / with statement
56 TEST_OUTPUT:
57 ---
58 fail_compilation/goto2.d(1121): Error: cannot `goto` into `try` block
59 ---
61 #line 1100
63 int interpret3a()
65 // enter to TryCatchStatement.body
67 bool c = false;
68 try
70 if (c) // need to bypass front-end optimization
71 throw new Exception("");
72 else
74 goto Lx;
75 L1:
76 c = true;
79 catch (Exception e) {}
81 Lx:
82 if (!c)
83 goto L1;
85 return 1;
88 /**************************************************
89 https://issues.dlang.org/show_bug.cgi?id=11540
90 goto label + try-catch-finally / with statement
92 TEST_OUTPUT:
93 ---
94 fail_compilation/goto2.d(1217): Error: cannot `goto` into `try` block
95 ---
97 #line 1200
99 int interpret3b()
101 // enter back to TryFinallyStatement.body
103 bool c = false;
106 goto Lx;
108 c = true;
110 finally {
114 if (!c)
115 goto L1;
118 return 1;
121 /**************************************************
122 https://issues.dlang.org/show_bug.cgi?id=13815
124 TEST_OUTPUT:
126 fail_compilation/goto2.d(1234): Error: cannot `goto` into `try` block
130 bool f()
132 goto L;
135 L: // line 7
136 throw new Exception(""); // line 8
138 catch (Exception e)
140 return true;
142 return false;