aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/checker.cpp4
-rw-r--r--src/docs_writer.cpp2
-rw-r--r--src/error.cpp4
-rw-r--r--src/llvm_backend.cpp14
-rw-r--r--src/main.cpp2
-rw-r--r--src/parser.cpp4
6 files changed, 17 insertions, 13 deletions
diff --git a/src/checker.cpp b/src/checker.cpp
index 836f803fc..0efe61fba 100644
--- a/src/checker.cpp
+++ b/src/checker.cpp
@@ -1204,7 +1204,7 @@ gb_internal void init_universal(void) {
}
if (defined_values_double_declaration) {
- gb_exit(1);
+ exit_with_errors();
}
@@ -4504,7 +4504,7 @@ gb_internal void add_import_dependency_node(Checker *c, Ast *decl, PtrMap<AstPac
if (found == nullptr) {
Token token = ast_token(decl);
error(token, "Unable to find package: %.*s", LIT(path));
- gb_exit(1);
+ exit_with_errors();
}
AstPackage *pkg = *found;
GB_ASSERT(pkg->scope != nullptr);
diff --git a/src/docs_writer.cpp b/src/docs_writer.cpp
index 26d8027a9..824445ed5 100644
--- a/src/docs_writer.cpp
+++ b/src/docs_writer.cpp
@@ -1170,7 +1170,7 @@ gb_internal void odin_doc_write_to_file(OdinDocWriter *w, char const *filename)
gbFileError err = gb_file_open_mode(&f, gbFileMode_Write, filename);
if (err != gbFileError_None) {
gb_printf_err("Failed to write .odin-doc to: %s\n", filename);
- gb_exit(1);
+ exit_with_errors();
return;
}
defer (gb_file_close(&f));
diff --git a/src/error.cpp b/src/error.cpp
index 509470602..8d550e969 100644
--- a/src/error.cpp
+++ b/src/error.cpp
@@ -613,6 +613,10 @@ gb_internal void compiler_error(char const *fmt, ...) {
}
+gb_internal void exit_with_errors(void) {
+ print_all_errors();
+ gb_exit(1);
+}
diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp
index b8ee7e7fa..cc9b3ac5d 100644
--- a/src/llvm_backend.cpp
+++ b/src/llvm_backend.cpp
@@ -1350,7 +1350,7 @@ gb_internal WORKER_TASK_PROC(lb_llvm_emit_worker_proc) {
if (LLVMTargetMachineEmitToFile(wd->target_machine, wd->m->mod, cast(char *)wd->filepath_obj.text, wd->code_gen_file_type, &llvm_error)) {
gb_printf_err("LLVM Error: %s\n", llvm_error);
- gb_exit(1);
+ exit_with_errors();
}
debugf("Generated File: %.*s\n", LIT(wd->filepath_obj));
return 0;
@@ -1919,7 +1919,7 @@ verify
gb_printf_err("LLVM Error: %s\n", llvm_error);
}
}
- gb_exit(1);
+ exit_with_errors();
return 1;
}
#endif
@@ -2104,11 +2104,11 @@ gb_internal WORKER_TASK_PROC(lb_llvm_module_verification_worker_proc) {
String filepath_ll = lb_filepath_ll_for_module(m);
if (LLVMPrintModuleToFile(m->mod, cast(char const *)filepath_ll.text, &llvm_error)) {
gb_printf_err("LLVM Error: %s\n", llvm_error);
- gb_exit(1);
+ exit_with_errors();
return false;
}
}
- gb_exit(1);
+ exit_with_errors();
return 1;
}
return 0;
@@ -2193,7 +2193,7 @@ gb_internal bool lb_llvm_object_generation(lbGenerator *gen, bool do_threading)
if (LLVMTargetMachineEmitToFile(m->target_machine, m->mod, cast(char *)filepath_obj.text, code_gen_file_type, &llvm_error)) {
gb_printf_err("LLVM Error: %s\n", llvm_error);
- gb_exit(1);
+ exit_with_errors();
return false;
}
debugf("Generated File: %.*s\n", LIT(filepath_obj));
@@ -2393,7 +2393,7 @@ gb_internal void lb_generate_procedure(lbModule *m, lbProcedure *p) {
gb_printf_err("LLVM Error: %s\n", llvm_error);
}
LLVMVerifyFunction(p->value, LLVMPrintMessageAction);
- gb_exit(1);
+ exit_with_errors();
}
}
@@ -2962,7 +2962,7 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
String filepath_ll = lb_filepath_ll_for_module(m);
if (LLVMPrintModuleToFile(m->mod, cast(char const *)filepath_ll.text, &llvm_error)) {
gb_printf_err("LLVM Error: %s\n", llvm_error);
- gb_exit(1);
+ exit_with_errors();
return false;
}
array_add(&gen->output_temp_paths, filepath_ll);
diff --git a/src/main.cpp b/src/main.cpp
index 672a9318e..ab721a143 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1404,7 +1404,7 @@ gb_internal void timings_export_all(Timings *t, Checker *c, bool timings_are_fin
gbFileError err = gb_file_open_mode(&f, gbFileMode_Write, fileName);
if (err != gbFileError_None) {
gb_printf_err("Failed to export timings to: %s\n", fileName);
- gb_exit(1);
+ exit_with_errors();
return;
} else {
gb_printf("\nExporting timings to '%s'... ", fileName);
diff --git a/src/parser.cpp b/src/parser.cpp
index 14035d6d7..1aa40ccbf 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -1484,7 +1484,7 @@ gb_internal Token expect_token(AstFile *f, TokenKind kind) {
String p = token_to_string(prev);
syntax_error(f->curr_token, "Expected '%.*s', got '%.*s'", LIT(c), LIT(p));
if (prev.kind == Token_EOF) {
- gb_exit(1);
+ exit_with_errors();
}
}
@@ -6177,7 +6177,7 @@ gb_internal ParseFileError process_imported_file(Parser *p, ImportedFile importe
if (err == ParseFile_EmptyFile) {
if (fi.fullpath == p->init_fullpath) {
syntax_error(pos, "Initial file is empty - %.*s\n", LIT(p->init_fullpath));
- gb_exit(1);
+ exit_with_errors();
}
} else {
switch (err) {