Skip to content

Commit

Permalink
Warn when setting used on the command line more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 committed Mar 2, 2024
1 parent 53f661c commit be27fe3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<class 'dict'>)", 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 <stdio.h>
Expand Down

0 comments on commit be27fe3

Please sign in to comment.