diff --git a/core/src/main/java/org/teavm/backend/c/generate/CodeGenerationVisitor.java b/core/src/main/java/org/teavm/backend/c/generate/CodeGenerationVisitor.java index 8b76c9c8c..34fd40db9 100644 --- a/core/src/main/java/org/teavm/backend/c/generate/CodeGenerationVisitor.java +++ b/core/src/main/java/org/teavm/backend/c/generate/CodeGenerationVisitor.java @@ -1217,6 +1217,10 @@ public class CodeGenerationVisitor implements ExprVisitor, StatementVisitor { } writer.println(";"); + if (context.isLongjmp()) { + writer.println("TEAVM_UNREACHABLE"); + } + popLocation(statement.getLocation()); } diff --git a/core/src/main/resources/org/teavm/backend/c/runtime.h b/core/src/main/resources/org/teavm/backend/c/runtime.h index 2bbc0b3d7..0deac2877 100644 --- a/core/src/main/resources/org/teavm/backend/c/runtime.h +++ b/core/src/main/resources/org/teavm/backend/c/runtime.h @@ -418,6 +418,17 @@ inline static void* teavm_nullCheck(void* o) { } return o; } + +#ifdef __GNUC__ + #define TEAVM_UNREACHABLE __builtin_unreachable(); +#endif +#ifdef _MSC_VER + #define TEAVM_UNREACHABLE __assume(0); +#endif +#ifndef TEAVM_UNREACHABLE + #define TEAVM_UNREACHABLE return; +#endif + #else #define TEAVM_JUMP_SUPPORTED 0 #define TEAVM_JUMP_TO_FRAME(frame, id)