Make compiler return non-zero exit code when include file not found.
Most pre-processor errors are flagged to the main compiler by a comment at the end of the pre-processed output. But certain errors, such as failing to find or open an include file, cause the pre-processor to exit immediately, which bypassed the generation of that comment. So we need to also generate that comment for all early-exit cases. This fixes issue #1104.
This commit is contained in:
parent
0679d7c8cf
commit
2799799358
|
|
@ -1015,13 +1015,19 @@ static /* inline */ char* def_argv(int arg)
|
|||
return def_buf + def_argo[arg];
|
||||
}
|
||||
|
||||
static void early_exit(void)
|
||||
{
|
||||
fprintf(yyout, "// Icarus preprocessor had (%u) errors.\n", error_count);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void check_for_max_args(void)
|
||||
{
|
||||
if (def_argc == MAX_DEF_ARG) {
|
||||
emit_pathline(istack);
|
||||
fprintf(stderr, "error: too many macro arguments - aborting\n");
|
||||
error_count += 1;
|
||||
exit(1);
|
||||
early_exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1930,7 +1936,7 @@ static void include_filename(int macro_str)
|
|||
fprintf(stderr,
|
||||
"error: malformed `include directive. Extra junk on line?\n");
|
||||
error_count += 1;
|
||||
exit(1);
|
||||
early_exit();
|
||||
}
|
||||
|
||||
standby = malloc(sizeof(struct include_stack_t));
|
||||
|
|
@ -1987,7 +1993,8 @@ static void do_include(void)
|
|||
|
||||
emit_pathline(istack);
|
||||
fprintf(stderr, "Include file %s not found\n", standby->path);
|
||||
exit(1);
|
||||
error_count += 1;
|
||||
early_exit();
|
||||
|
||||
code_that_switches_buffers:
|
||||
|
||||
|
|
@ -2366,7 +2373,8 @@ void reset_lexor(FILE* out, char* paths[])
|
|||
|
||||
if (isp->file == 0) {
|
||||
perror(paths[0]);
|
||||
exit(1);
|
||||
error_count += 1;
|
||||
early_exit();
|
||||
}
|
||||
|
||||
if (depend_file) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue