| ... | @@ -1042,6 +1042,44 @@ pub fn addCases(cases: &tests.TranslateCContext) { | ... | @@ -1042,6 +1042,44 @@ pub fn addCases(cases: &tests.TranslateCContext) { |
| 1042 | \\ return x + 13; | 1042 | \\ return x + 13; |
| 1043 | \\} | 1043 | \\} |
| 1044 | ); | 1044 | ); |
| | 1045 | |
| | 1046 | cases.add("switch statement with no default", |
| | 1047 | \\int foo(int x) { |
| | 1048 | \\ switch (x) { |
| | 1049 | \\ case 1: |
| | 1050 | \\ x += 1; |
| | 1051 | \\ case 2: |
| | 1052 | \\ break; |
| | 1053 | \\ case 3: |
| | 1054 | \\ case 4: |
| | 1055 | \\ return x + 1; |
| | 1056 | \\ } |
| | 1057 | \\ return x + 13; |
| | 1058 | \\} |
| | 1059 | , |
| | 1060 | \\fn foo(_arg_x: c_int) -> c_int { |
| | 1061 | \\ var x = _arg_x; |
| | 1062 | \\ { |
| | 1063 | \\ switch (x) { |
| | 1064 | \\ 1 => goto case_0, |
| | 1065 | \\ 2 => goto case_1, |
| | 1066 | \\ 3 => goto case_2, |
| | 1067 | \\ 4 => goto case_3, |
| | 1068 | \\ else => goto end, |
| | 1069 | \\ }; |
| | 1070 | \\ case_0: |
| | 1071 | \\ x += 1; |
| | 1072 | \\ case_1: |
| | 1073 | \\ goto end; |
| | 1074 | \\ case_2: |
| | 1075 | \\ case_3: |
| | 1076 | \\ return x + 1; |
| | 1077 | \\ goto end; |
| | 1078 | \\ end: |
| | 1079 | \\ }; |
| | 1080 | \\ return x + 13; |
| | 1081 | \\} |
| | 1082 | ); |
| 1045 | } | 1083 | } |
| 1046 | | 1084 | |
| 1047 | | 1085 | |