C: generate unreachable hint after throw statement to avoid compiler warnings

This commit is contained in:
Alexey Andreev 2019-07-23 18:19:40 +03:00
parent ca3b565210
commit a9ba21889a
2 changed files with 15 additions and 0 deletions

View File

@ -1217,6 +1217,10 @@ public class CodeGenerationVisitor implements ExprVisitor, StatementVisitor {
}
writer.println(";");
if (context.isLongjmp()) {
writer.println("TEAVM_UNREACHABLE");
}
popLocation(statement.getLocation());
}

View File

@ -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)