authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-11-29 23:09:35-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-11-29 23:09:35-05:00
log210d0017c40ee24215ce705fcee342fe34b9dccb
treea558e09c2da78d3c506266adae7e378c76c0ce0f
parent7729f6cf4edd7c8eda935b1c7c8b4276d73b6e69

fix build broken by previous commit

now we report a compile error for unusual failures from translate-c

4 files changed, 7 insertions(+), 2 deletions(-)

src/error.cpp+1
...@@ -26,6 +26,7 @@ const char *err_str(int err) {...@@ -26,6 +26,7 @@ const char *err_str(int err) {
26 case ErrorExactDivRemainder: return "exact division had a remainder";26 case ErrorExactDivRemainder: return "exact division had a remainder";
27 case ErrorNegativeDenominator: return "negative denominator";27 case ErrorNegativeDenominator: return "negative denominator";
28 case ErrorShiftedOutOneBits: return "exact shift shifted out one bits";28 case ErrorShiftedOutOneBits: return "exact shift shifted out one bits";
29 case ErrorCCompileErrors: return "C compile errors";
29 }30 }
30 return "(invalid error)";31 return "(invalid error)";
31}32}
src/error.hpp+1
...@@ -26,6 +26,7 @@ enum Error {...@@ -26,6 +26,7 @@ enum Error {
26 ErrorExactDivRemainder,26 ErrorExactDivRemainder,
27 ErrorNegativeDenominator,27 ErrorNegativeDenominator,
28 ErrorShiftedOutOneBits,28 ErrorShiftedOutOneBits,
29 ErrorCCompileErrors,
29};30};
3031
31const char *err_str(int err);32const char *err_str(int err);
src/ir.cpp+4-1
...@@ -13870,7 +13870,10 @@ static TypeTableEntry *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruc...@@ -13870,7 +13870,10 @@ static TypeTableEntry *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruc
1387013870
13871 int err;13871 int err;
13872 if ((err = parse_h_buf(child_import, &errors, &cimport_scope->buf, ira->codegen, node))) {13872 if ((err = parse_h_buf(child_import, &errors, &cimport_scope->buf, ira->codegen, node))) {
13873 zig_panic("unable to parse C file: %s\n", err_str(err));13873 if (err != ErrorCCompileErrors) {
13874 ir_add_error_node(ira, node, buf_sprintf("C import failed: %s", err_str(err)));
13875 return ira->codegen->builtin_types.entry_invalid;
13876 }
13874 }13877 }
1387513878
13876 if (errors.length > 0) {13879 if (errors.length > 0) {
src/translate_c.cpp+1-1
...@@ -4313,7 +4313,7 @@ int parse_h_file(ImportTableEntry *import, ZigList<ErrorMsg *> *errors, const ch...@@ -4313,7 +4313,7 @@ int parse_h_file(ImportTableEntry *import, ZigList<ErrorMsg *> *errors, const ch
4313 }4313 }
4314 }4314 }
43154315
4316 return ErrorUnexpected;4316 return ErrorCCompileErrors;
4317 }4317 }
43184318
4319 c->ctx = &ast_unit->getASTContext();4319 c->ctx = &ast_unit->getASTContext();