Lassi Pulkkinen: 2
driver: Discard unused inputs before complaining about having too many
driver: Ignore -pedantic-errors
3 files changed, 13 insertions(+), 6 deletions(-)
Fixes e.g. cproc -lm -S a.c -o a.
---
v2: Dumb mistake in the commit message - the bug needs an explicit
output.
driver.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/driver.c b/driver.c
index 2ead711..255903a 100644
--- a/driver.c+++ b/driver.c
@@ -564,6 +564,16 @@ main(int argc, char *argv[])
stages[i].cmdbase = stages[i].cmd.len;
if (inputs.len == 0)
usage(NULL);
+ i = 0;+ arrayforeach (&inputs, input) {+ /* discard the input if it doesn't participate in the last stage */+ if (!(input->stages & 1 << last))+ continue;+ /* only run up through the last stage */+ input->stages &= (1 << last + 1) - 1;+ ((struct input *)inputs.val)[i++] = *input;+ }+ inputs.len = i * sizeof(*input); if (output) {
if (strcmp(output, "-") == 0) {
if (last >= ASSEMBLE)
@@ -573,11 +583,6 @@ main(int argc, char *argv[])
}
}
arrayforeach (&inputs, input) {
- /* ignore the input if it doesn't participate in the last stage */- if (!(input->stages & 1 << last))- continue;- /* only run up through the last stage */- input->stages &= (1 << last + 1) - 1; buildobj(input, output);
}
if (last == LINK) {
--
2.45.0