Warning for multiple CATCH blocks

This commit is contained in:
Volker Berlin 2019-11-28 20:07:51 +01:00
parent 1a89919984
commit 724f39dc18
2 changed files with 21 additions and 0 deletions

View File

@ -741,6 +741,14 @@ class BranchManger {
int idx;
for( idx = 0; idx < parsedOperations.size(); idx++ ) {
ParsedBlock parsedBlock = parsedOperations.get( idx );
if( parsedBlock.op == JavaBlockOperator.TRY ) {
TryCatchFinally tryCatch2 = ((TryCatchParsedBlock)parsedBlock).tryCatch;
if( tryCatch.getStart() == tryCatch2.getStart() && tryCatch.getEnd() == tryCatch2.getEnd() ) {
throw new WasmException( "Try with multiple catch blocks can't compile currently.", null, null, tryBlock.lineNumber );
}
}
if( parsedBlock.startPosition == gotoPos && parsedBlock.op == JavaBlockOperator.GOTO && parsedBlock.startPosition < parsedBlock.endPosition ) {
parsedOperations.remove( idx );
endPos = parsedBlock.endPosition;

View File

@ -130,6 +130,19 @@ public class Exceptions extends AbstractBaseTest {
return v;
}
// @Export
// static int multiCatch() {
// int r;
// try {
// r = 5 / 0;
// } catch(RuntimeException ex ) {
// r = 1;
// } catch(Exception ex ) {
// r = 2;
// }
// return r;
// }
// @Export
// static int npe() {
// Object obj = new NullPointerException();