@no_wasm_backend('DEAD_FUNCTIONS elimination is done by the JSOptimizer')
def test_dead_functions(self):
    src = '\n      #include <stdio.h>\n      extern "C" {\n      __attribute__((noinline)) int unused(int x) {\n        volatile int y = x;\n        return y;\n      }\n      }\n      int main(int argc, char **argv) {\n        printf("*%d*\\n", argc > 1 ? unused(1) : 2);\n        return 0;\n      }\n    '
    self.do_run(src, '*1*', args=['x'])
    js = open('src.cpp.o.js').read()
    if (self.run_name in ['default', 'asm2g']):
        assert ('function _unused($' in js)
    self.do_run(None, '*2*', no_build=True)
    self.set_setting('DEAD_FUNCTIONS', ['_unused'])
    self.do_run(src, '*2*')
    self.do_run(None, 'abort(', args=['x'], no_build=True, assert_returncode=None)
    self.set_setting('DEAD_FUNCTIONS', ['_printf'])
    self.do_run(src, 'abort(', assert_returncode=None)
    self.do_run(None, 'abort(', args=['x'], no_build=True, assert_returncode=None)
@no_wasm_backend('DEAD_FUNCTIONS elimination is done by the JSOptimizer')
def test_dead_functions(self):
    src = '\n      #include <stdio.h>\n      extern "C" {\n      __attribute__((noinline)) int unused(int x) {\n        volatile int y = x;\n        return y;\n      }\n      }\n      int main(int argc, char **argv) {\n        printf("*%d*\\n", argc > 1 ? unused(1) : 2);\n        return 0;\n      }\n    '
    self.do_run(src, '*1*', args=['x'])
    js = open('src.cpp.o.js').read()
    if (self.run_name in ['default', 'asm2g']):
        assert ('function _unused($' in js)
    self.do_run(None, '*2*', no_build=True)
    self.set_setting('DEAD_FUNCTIONS', ['_unused'])
    self.do_run(src, '*2*')
    self.do_run(None, 'abort(', args=['x'], no_build=True, assert_returncode=None)
    self.set_setting('DEAD_FUNCTIONS', ['_printf'])
    self.do_run(src, 'abort(', assert_returncode=None)
    self.do_run(None, 'abort(', args=['x'], no_build=True, assert_returncode=None)