aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/jsifier.js2
-rw-r--r--src/library.js9
-rw-r--r--src/parseTools.js4
-rwxr-xr-xtests/runner.py4
4 files changed, 11 insertions, 8 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 44d9cc53..b9209dd2 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -1150,7 +1150,7 @@ function JSify(data, functionsOnly, givenFunctions) {
var ptr = makeStructuralAccess(item.ident, 0);
return (EXCEPTION_DEBUG ? 'Module.print("Resuming exception");' : '') +
'if (' + makeGetValue('_llvm_eh_exception.buf', 0, 'void*') + ' == 0) { ' + makeSetValue('_llvm_eh_exception.buf', 0, ptr, 'void*') + ' } ' +
- 'throw ' + ptr + ';';
+ makeThrow('ptr') + ';';
});
makeFuncLineActor('invoke', function(item) {
// Wrapping in a function lets us easily return values if we are
diff --git a/src/library.js b/src/library.js
index 7ae17fb7..b70aadbc 100644
--- a/src/library.js
+++ b/src/library.js
@@ -4894,12 +4894,12 @@ LibraryManager.library = {
} else {
__ZSt18uncaught_exceptionv.uncaught_exception++;
}
- throw ptr;
+ {{{ makeThrow('ptr') }}};
},
__cxa_rethrow__deps: ['llvm_eh_exception', '__cxa_end_catch'],
__cxa_rethrow: function() {
___cxa_end_catch.rethrown = true;
- throw {{{ makeGetValue('_llvm_eh_exception.buf', '0', 'void*') }}};
+ {{{ makeThrow(makeGetValue('_llvm_eh_exception.buf', '0', 'void*')) }}};
},
llvm_eh_exception__postset: '_llvm_eh_exception.buf = allocate(12, "void*", ALLOC_STATIC);',
llvm_eh_exception: function() {
@@ -4962,11 +4962,10 @@ LibraryManager.library = {
},
_Unwind_Resume_or_Rethrow: function(ptr) {
- throw ptr;
+ {{{ makeThrow('ptr') }}};
},
- _Unwind_RaiseException__deps: ['llvm_eh_exception', '__cxa_find_matching_catch'],
_Unwind_RaiseException: function(ptr) {
- throw ptr;
+ {{{ makeThrow('ptr') }}};
},
_Unwind_DeleteException: function(ptr) {},
diff --git a/src/parseTools.js b/src/parseTools.js
index 32bf70e9..07e044b9 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -1666,6 +1666,10 @@ function makeStructuralAccess(ident, i) {
}
}
+function makeThrow(what) {
+ return 'throw ' + what + (DISABLE_EXCEPTION_CATCHING ? ' + " - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 to catch."' : '') + ';';
+}
+
// From parseLLVMSegment
function finalizeLLVMParameter(param, noIndexizeFunctions) {
var ret;
diff --git a/tests/runner.py b/tests/runner.py
index 30f5213b..9095d395 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -2316,8 +2316,8 @@ Exception execution path of first function! 1
self.do_run(src, '*throw...caught!infunc...done!*')
Settings.DISABLE_EXCEPTION_CATCHING = 1
- self.do_run(src, 'Compiled code throwing an exception')
-
+ self.do_run(src, 'Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 to catch.')
+
src = '''
#include <iostream>