@@ -278,6 +278,19 @@ void test_core() {
278278 BinaryenModuleDispose (module );
279279}
280280
281+ void test_unreachable () {
282+ BinaryenModuleRef module = BinaryenModuleCreate ();
283+ BinaryenFunctionTypeRef i = BinaryenAddFunctionType (module , "i" , BinaryenInt32 (), NULL , 0 );
284+ BinaryenFunctionTypeRef I = BinaryenAddFunctionType (module , "I" , BinaryenInt64 (), NULL , 0 );
285+
286+ BinaryenExpressionRef body = BinaryenCallIndirect (module , BinaryenUnreachable (module ), NULL , 0 , "I" );
287+ BinaryenFunctionRef fn = BinaryenAddFunction (module , "unreachable-fn" , i , NULL , 0 , body );
288+
289+ assert (BinaryenModuleValidate (module ));
290+ BinaryenModulePrint (module );
291+ BinaryenModuleDispose (module );
292+ }
293+
281294BinaryenExpressionRef makeCallCheck (BinaryenModuleRef module , int x ) {
282295 BinaryenExpressionRef callOperands [] = { makeInt32 (module , x ) };
283296 return BinaryenCallImport (module , "check" , callOperands , 1 , BinaryenNone ());
@@ -556,6 +569,7 @@ void test_tracing() {
556569int main () {
557570 test_types ();
558571 test_core ();
572+ test_unreachable ();
559573 test_relooper ();
560574 test_binaries ();
561575 test_interpret ();
0 commit comments