summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorturki.s <43733538+nilput@users.noreply.github.com>2018-10-26 15:01:57 +0200
committerSebastian Buchwald <UniQP@users.noreply.github.com>2018-10-26 15:01:57 +0200
commit1cd7810f7e8960af490ac2ca0abab63f9da45847 (patch)
tree1cecfea3cdd66533b79e2b620707e361861a073b
parent3e00440a231132c09af2927300bfdf57111e5564 (diff)
prevent overwriting source files (#17)
prevent overwriting source files
-rw-r--r--src/driver/driver.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/driver/driver.c b/src/driver/driver.c
index 634d1cc..639d8d4 100644
--- a/src/driver/driver.c
+++ b/src/driver/driver.c
@@ -245,6 +245,10 @@ bool process_all_units(compilation_env_t *env)
for (compilation_unit_t *unit = units; unit != NULL; unit = unit->next) {
if (unit->type == COMPILATION_UNIT_AUTODETECT)
unit->type = autodetect_input(unit->name);
+ if (unit->original_name && env->outname && streq(unit->original_name, env->outname)) {
+ errorf(NULL, "output file '%s' is the same as the input file", env->outname);
+ return false;
+ }
stat_ev_ctx_push_str("compilation_unit", unit->name);
bool ok = process_unit(env, unit);