From 210d0017c40ee24215ce705fcee342fe34b9dccb Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 29 Nov 2017 23:09:35 -0500 Subject: [PATCH] fix build broken by previous commit now we report a compile error for unusual failures from translate-c --- src/error.cpp | 1 + src/error.hpp | 1 + src/ir.cpp | 5 ++++- src/translate_c.cpp | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/error.cpp b/src/error.cpp index a6953d4ab34fb3301dd44f985ec31d86f8018313..8303a80a1de39ac8171f41e85e14c0d974c4391e 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -26,6 +26,7 @@ const char *err_str(int err) { case ErrorExactDivRemainder: return "exact division had a remainder"; case ErrorNegativeDenominator: return "negative denominator"; case ErrorShiftedOutOneBits: return "exact shift shifted out one bits"; + case ErrorCCompileErrors: return "C compile errors"; } return "(invalid error)"; } diff --git a/src/error.hpp b/src/error.hpp index d7d9c45baf7dcb87a20863e9d57b340715332f59..e3b87fc6b85f331e28bbc68c66afdfce69d55f3f 100644 --- a/src/error.hpp +++ b/src/error.hpp @@ -26,6 +26,7 @@ enum Error { ErrorExactDivRemainder, ErrorNegativeDenominator, ErrorShiftedOutOneBits, + ErrorCCompileErrors, }; const char *err_str(int err); diff --git a/src/ir.cpp b/src/ir.cpp index f1dc1e1b4d1b2fab2ba0b6482141e8d47860ba56..e3f223a595b1953178e3db4cb9d835bb62b31f8a 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -13870,7 +13870,10 @@ static TypeTableEntry *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruc int err; if ((err = parse_h_buf(child_import, &errors, &cimport_scope->buf, ira->codegen, node))) { - zig_panic("unable to parse C file: %s\n", err_str(err)); + if (err != ErrorCCompileErrors) { + ir_add_error_node(ira, node, buf_sprintf("C import failed: %s", err_str(err))); + return ira->codegen->builtin_types.entry_invalid; + } } if (errors.length > 0) { diff --git a/src/translate_c.cpp b/src/translate_c.cpp index f89444a5eec0d9906364fba6e29b354f507d4eea..3dafa757d95e62d35e1ce8b6d3b5390343086e81 100644 --- a/src/translate_c.cpp +++ b/src/translate_c.cpp @@ -4313,7 +4313,7 @@ int parse_h_file(ImportTableEntry *import, ZigList *errors, const ch } } - return ErrorUnexpected; + return ErrorCCompileErrors; } c->ctx = &ast_unit->getASTContext(); -- 2.54.0