aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-01-30 12:23:27 -0800
committerAlon Zakai <alonzakai@gmail.com>2014-01-30 12:23:27 -0800
commit5cae031ff9a7551b6f244b110303e26bfa54076b (patch)
tree79f00f478f5518cdc4564952d3c88e9ebe9b9110 /tests
parentf7566449e9c0e367b092999e1f3e5102f854bda9 (diff)
fix exceptions whitelist check on invoke using function pointer; fixes #2081
Diffstat (limited to 'tests')
-rw-r--r--tests/core/test_exceptions_white_list_2.c27
-rw-r--r--tests/core/test_exceptions_white_list_2.out1
-rw-r--r--tests/test_core.py12
3 files changed, 38 insertions, 2 deletions
diff --git a/tests/core/test_exceptions_white_list_2.c b/tests/core/test_exceptions_white_list_2.c
new file mode 100644
index 00000000..40d7c56c
--- /dev/null
+++ b/tests/core/test_exceptions_white_list_2.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+
+void throwhere(void) {
+ throw(1);
+}
+
+void (*funptr)(void) = throwhere;
+
+void nocatch(void) {
+ try {
+ funptr();
+ }
+ catch (...) {
+ printf("ERROR\n");
+ }
+}
+
+int main(void) {
+ try {
+ nocatch();
+ }
+ catch (...) {
+ printf("SUCCESS\n");
+ }
+ return 0;
+}
+
diff --git a/tests/core/test_exceptions_white_list_2.out b/tests/core/test_exceptions_white_list_2.out
new file mode 100644
index 00000000..ff43ca40
--- /dev/null
+++ b/tests/core/test_exceptions_white_list_2.out
@@ -0,0 +1 @@
+SUCCESS
diff --git a/tests/test_core.py b/tests/test_core.py
index 18d7d74a..6c2968f6 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -1299,8 +1299,16 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
self.do_run_from_file(src, output)
- Settings.DISABLE_EXCEPTION_CATCHING = 0
- Settings.EXCEPTION_CATCHING_WHITELIST = []
+ def test_exceptions_white_list_2(self):
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
+
+ Settings.DISABLE_EXCEPTION_CATCHING = 2
+ Settings.EXCEPTION_CATCHING_WHITELIST = ["_main"]
+ Settings.INLINING_LIMIT = 50 # otherwise it is inlined and not identified
+
+ test_path = path_from_root('tests', 'core', 'test_exceptions_white_list_2')
+ src, output = (test_path + s for s in ('.c', '.out'))
+ self.do_run_from_file(src, output)
def test_exceptions_uncaught(self):
if self.emcc_args is None: return self.skip('no libcxx inclusion without emcc')