aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-03-03 14:41:24 -0800
committerAlon Zakai <alonzakai@gmail.com>2014-03-03 15:38:42 -0800
commit7f45922c7ffa3c8591344b2851373c70a4bf05ae (patch)
treefefbc76acde8988acb71a9a3911da1532ab11bad
parentbc921f43a57650c50f609b14e19f54c3d2f32cc5 (diff)
enable errors on implicit functions by default; fixes #2175
-rw-r--r--tests/cubegeom_color.c4
-rw-r--r--tests/full_es2_sdlproc.c2
-rw-r--r--tests/sdl_headless.c3
-rw-r--r--tests/test_other.py22
-rw-r--r--tools/shared.py9
5 files changed, 26 insertions, 14 deletions
diff --git a/tests/cubegeom_color.c b/tests/cubegeom_color.c
index 0d2b6ecb..7a41c64d 100644
--- a/tests/cubegeom_color.c
+++ b/tests/cubegeom_color.c
@@ -38,10 +38,6 @@ void verify() {
for (int x = 0; x < width*height*4; x++) {
if (x % 4 != 3) sum += x * data[x];
}
-#ifdef __EMSCRIPTEN__
- int result = sum;
- REPORT_RESULT();
-#endif
}
int main(int argc, char *argv[])
diff --git a/tests/full_es2_sdlproc.c b/tests/full_es2_sdlproc.c
index d9ac072b..3f72f2bf 100644
--- a/tests/full_es2_sdlproc.c
+++ b/tests/full_es2_sdlproc.c
@@ -704,6 +704,8 @@ gears_init(void)
gear3 = create_gear(1.3, 2.0, 0.5, 10, 0.7);
}
+#include "SDL/SDL.h"
+
int
main(int argc, char *argv[])
{
diff --git a/tests/sdl_headless.c b/tests/sdl_headless.c
index 6157a46d..e1836777 100644
--- a/tests/sdl_headless.c
+++ b/tests/sdl_headless.c
@@ -57,9 +57,6 @@ int main(int argc, char **argv) {
printf("done.\n");
- int result = sum > 3000 && sum < 5000; // varies a little on different browsers, font differences?
- REPORT_RESULT();
-
return 0;
}
diff --git a/tests/test_other.py b/tests/test_other.py
index e381e1b3..2fecf09e 100644
--- a/tests/test_other.py
+++ b/tests/test_other.py
@@ -2521,16 +2521,24 @@ int main()
}
''')
+ IMPLICIT_WARNING = '''warning: implicit declaration of function 'strnlen' is invalid in C99'''
+ IMPLICIT_ERROR = '''error: implicit declaration of function 'strnlen' is invalid in C99'''
+
for opts, expected, compile_expected in [
- ([], ['abort()', 'it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this'], []),
- (['-s', 'ASSERTIONS=2'], ['abort()', 'This pointer might make sense in another type signature'], []),
- (['-O1'], ['hello 2\nhello 5\n'], []), # invalid output - second arg is sent as varargs, but needs to be int. llvm optimizer avoided the crash silently, caused undefined behavior... at least people can debug this by running an -O0 build.
+ ([], None, [IMPLICIT_ERROR]),
+ (['-Wno-error=implicit-function-declaration'], ['abort()', 'it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this'], [IMPLICIT_WARNING]), # turn error into warning
+ (['-Wno-implicit-function-declaration'], ['abort()', 'it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this'], []), # turn error into nothing at all
+ (['-Wno-error=implicit-function-declaration', '-s', 'ASSERTIONS=2'], ['abort()', 'This pointer might make sense in another type signature'], []),
+ (['-Wno-error=implicit-function-declaration', '-O1'], ['hello 2\nhello 5\n'], []), # invalid output - second arg is sent as varargs, but needs to be int. llvm optimizer avoided the crash silently, caused undefined behavior... at least people can debug this by running an -O0 build.
]:
print opts, expected
stdout, stderr = Popen([PYTHON, EMCC, 'src.c'] + opts, stderr=PIPE).communicate()
- output = run_js(os.path.join(self.get_dir(), 'a.out.js'), stderr=PIPE, full_output=True)
- for e in expected:
- self.assertContained(e, output)
- for ce in compile_expected + ['''warning: implicit declaration of function 'strnlen' is invalid in C99''', '''warning: incompatible pointer types''']:
+ for ce in compile_expected + ['''warning: incompatible pointer types''']:
self.assertContained(ce, stderr)
+ if expected is None:
+ assert not os.path.exists('a.out.js')
+ else:
+ output = run_js(os.path.join(self.get_dir(), 'a.out.js'), stderr=PIPE, full_output=True)
+ for e in expected:
+ self.assertContained(e, output)
diff --git a/tools/shared.py b/tools/shared.py
index 31f0aad9..533906c9 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -662,6 +662,15 @@ if LLVM_TARGET != 'asmjs-unknown-emscripten':
COMPILER_OPTS += ['-DEMSCRIPTEN', '-D__EMSCRIPTEN__', '-fno-math-errno',
'-U__native_client__', '-U__pnacl__', '-U__ELF__']
+# Changes to default clang behavior
+if LLVM_TARGET == 'asmjs-unknown-emscripten' or LLVM_TARGET == 'le32-unknown-nacl':
+ # Implicit functions can cause horribly confusing asm.js function pointer type errors, see #2175
+ # If your codebase really needs them - very unrecommended! - you can disable the error with
+ # -Wno-error=implicit-function-declaration
+ # or disable even a warning about it with
+ # -Wno-implicit-function-declaration
+ COMPILER_OPTS += ['-Werror=implicit-function-declaration']
+
USE_EMSDK = not os.environ.get('EMMAKEN_NO_SDK')
if USE_EMSDK: