| author | |
| committer | |
| log | 3ca861c7dd048a8bc15b6776a3b56fdc790750f7 |
| tree | 2db2fe9f4803b242b582f80959a6cc2928fd29e0 |
| parent | 0f54728cf0e282ca6578bb8a55df3409541c1a7f |
| signature |
closes #5582 files changed, 15 insertions(+), 0 deletions(-)
src/ir.cpp+4| ... | @@ -18705,6 +18705,10 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct | ... | @@ -18705,6 +18705,10 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct |
| 18705 | 18705 | ||
| 18706 | if (errors.length > 0) { | 18706 | if (errors.length > 0) { |
| 18707 | ErrorMsg *parent_err_msg = ir_add_error_node(ira, node, buf_sprintf("C import failed")); | 18707 | ErrorMsg *parent_err_msg = ir_add_error_node(ira, node, buf_sprintf("C import failed")); |
| 18708 | if (ira->codegen->libc_link_lib == nullptr) { | ||
| 18709 | add_error_note(ira->codegen, parent_err_msg, node, | ||
| 18710 | buf_sprintf("libc headers not available; compilation does not link against libc")); | ||
| 18711 | } | ||
| 18708 | for (size_t i = 0; i < errors.length; i += 1) { | 18712 | for (size_t i = 0; i < errors.length; i += 1) { |
| 18709 | ErrorMsg *err_msg = errors.at(i); | 18713 | ErrorMsg *err_msg = errors.at(i); |
| 18710 | err_msg_add_note(parent_err_msg, err_msg); | 18714 | err_msg_add_note(parent_err_msg, err_msg); |
test/compile_errors.zig+11| ... | @@ -1,6 +1,17 @@ | ... | @@ -1,6 +1,17 @@ |
| 1 | const tests = @import("tests.zig"); | 1 | const tests = @import("tests.zig"); |
| 2 | 2 | ||
| 3 | pub fn addCases(cases: *tests.CompileErrorContext) void { | 3 | pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 4 | cases.addTest( | ||
| 5 | "libc headers note", | ||
| 6 | \\const c = @cImport(@cInclude("stdio.h")); | ||
| 7 | \\export fn entry() void { | ||
| 8 | \\ c.printf("hello, world!\n"); | ||
| 9 | \\} | ||
| 10 | , | ||
| 11 | ".tmp_source.zig:1:11: error: C import failed", | ||
| 12 | ".tmp_source.zig:1:11: note: libc headers not available; compilation does not link against libc", | ||
| 13 | ); | ||
| 14 | |||
| 4 | cases.addTest( | 15 | cases.addTest( |
| 5 | "comptime vector overflow shows the index", | 16 | "comptime vector overflow shows the index", |
| 6 | \\comptime { | 17 | \\comptime { |