Skip to content

Commit 54732ad

Browse files
committed
Use warn for printing #warning messages in JS libraries
Previously we were only writing the message to stderr, and not recording it as an actual warning. After this change, such messages are now reported as warnings and controllable using `-Werror`, etc.
1 parent c4e39ce commit 54732ad

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/parseTools.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export function preprocess(filename) {
180180
showStack.pop();
181181
} else if (first === '#warning') {
182182
if (showCurrentLine()) {
183-
printErr(
183+
warn(
184184
`${filename}:${i + 1}: #warning ${trimmed.substring(trimmed.indexOf(' ')).trim()}`,
185185
);
186186
}

test/test_other.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4919,6 +4919,13 @@ def test_jslib_warnings(self):
49194919
self.assertNotContained('This warning should not be present!', proc.stderr)
49204920
self.assertContained('warning_in_js_libraries.js:5: #warning This is a warning string!', proc.stderr)
49214921
self.assertContained('warning_in_js_libraries.js:7: #warning This is a second warning string!', proc.stderr)
4922+
self.assertContained('emcc: warning: warnings in JS library compilation [-Wjs-compiler]', proc.stderr)
4923+
4924+
err = self.expect_fail([EMCC, test_file('hello_world.c'), '--js-library', test_file('warning_in_js_libraries.js'), '-Werror'])
4925+
self.assertNotContained('This warning should not be present!', err)
4926+
self.assertContained('warning_in_js_libraries.js:5: #warning This is a warning string!', err)
4927+
self.assertContained('warning_in_js_libraries.js:7: #warning This is a second warning string!', err)
4928+
self.assertContained('emcc: error: warnings in JS library compilation [-Wjs-compiler] [-Werror]', err)
49224929

49234930
# Tests using the #error directive in JS library files
49244931
def test_jslib_errors(self):

0 commit comments

Comments
 (0)