diff --git a/emcc.py b/emcc.py index 985ab6c78bdd2..4ad5bc845c2b7 100644 --- a/emcc.py +++ b/emcc.py @@ -684,6 +684,9 @@ def phase_parse_arguments(state): for s in settings_changes: key, value = s.split('=', 1) key, value = normalize_boolean_setting(key, value) + old_value = user_settings.get(key) + if old_value and old_value != value: + diagnostics.warning('unused-command-line-argument', f'-s{key} specified multiple times. Ignoring previous value (`{old_value}`)') user_settings[key] = value # STRICT is used when applying settings so it needs to be applied first before diff --git a/test/test_other.py b/test/test_other.py index f200531dd0288..b5e1f030d68d1 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -7811,6 +7811,10 @@ def test_dash_s_bad_json_types(self): err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sEXPORTED_FUNCTIONS=[{"a":1}]']) self.assertContained("list members in settings must be strings (not $)", err) + def test_dash_s_repeated(self): + err = self.expect_fail([EMCC, '-Werror', test_file('hello_world.c'), '-sEXPORTED_FUNCTIONS=foo', '-sEXPORTED_FUNCTIONS=bar']) + self.assertContained('emcc: error: -sEXPORTED_FUNCTIONS specified multiple times. Ignoring previous value (`foo`) [-Wunused-command-line-argument]', err) + def test_zeroinit(self): create_file('src.c', r''' #include