Pass fail information from the preprocessor to the compiler

This commit is contained in:
Cary R 2021-01-10 18:22:20 -08:00
parent 85e8cc6c5f
commit 5f281d5f21
3 changed files with 26 additions and 1 deletions

View File

@ -1,7 +1,7 @@
#ifndef IVL_compiler_H
#define IVL_compiler_H
/*
* Copyright (c) 1999-2019 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2021 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -308,4 +308,6 @@ extern bool load_vpi_module(const char*path);
*/
extern ivl_sfunc_as_task_t def_sfunc_as_task;
extern void pre_process_failed(const char*text);
#endif /* IVL_compiler_H */

View File

@ -461,6 +461,11 @@ int main(int argc, char*argv[])
fclose(precomp_out);
}
if (error_count) {
if (out_path) fprintf(stderr, "%s: had (%u) errors.\n", argv[0], error_count);
fprintf(out, "// Icarus preprocessor had (%u) errors.\n", error_count);
}
if (out_path) fclose(out);
/* Free the source and include directory lists. */

18
main.cc
View File

@ -91,6 +91,7 @@ static void signals_handler(int sig)
/* Count errors detected in flag processing. */
unsigned flag_errors = 0;
static unsigned long pre_process_fail_count = 0;
const char*basedir = strdup(".");
@ -1161,6 +1162,12 @@ int main(int argc, char*argv[])
return rc;
}
if (pre_process_fail_count) {
cerr << "Preprocessor failed with " << pre_process_fail_count
<< " errors." << endl;
return pre_process_fail_count;
}
/* If the user did not give specific module(s) to start with,
then look for modules that are not instantiated anywhere. */
@ -1407,3 +1414,14 @@ static void find_module_mention(map<perm_string,bool>&check_map, PGenerate*schm)
find_module_mention(check_map, *cur);
}
}
void pre_process_failed(const char*text)
{
const char*num_start = strchr(text, '(') + 1;
unsigned long res;
char*rem;
res = strtoul(num_start, &rem, 10);
assert(res > 0);
assert(rem[0] == ')');
pre_process_fail_count += res;
}