Sema: avoid analyzing functions which failed when inlining

This commit is contained in:
Veikka Tuominen 2022-12-11 22:06:17 +02:00
parent e6588857df
commit 886fa455fa
5 changed files with 23 additions and 17 deletions

View File

@ -2257,6 +2257,9 @@ fn failWithOwnedErrorMsg(sema: *Sema, err_msg: *Module.ErrorMsg) CompileError {
sema.owner_decl.analysis = .sema_failure;
sema.owner_decl.generation = mod.generation;
}
if (sema.func) |func| {
func.state = .sema_failure;
}
const gop = mod.failed_decls.getOrPutAssumeCapacity(sema.owner_decl_index);
if (gop.found_existing) {
// If there are multiple errors for the same Decl, prefer the first one added.
@ -6385,6 +6388,7 @@ fn analyzeCall(
}),
else => unreachable,
};
if (!is_comptime_call and module_fn.state == .sema_failure) return error.AnalysisFail;
// Analyze the ZIR. The same ZIR gets analyzed into a runtime function
// or an inlined call depending on what union tag the `label` field is

View File

@ -0,0 +1,9 @@
// error
// backend=llvm
// target=x86_64-linux
// output_mode=Exe
//
// :?:?: error: root struct of file 'tmp' has no member named 'main'
// :?:?: note: called from here

View File

@ -0,0 +1,10 @@
fn main() void {}
// error
// backend=llvm
// target=x86_64-linux
// output_mode=Exe
//
// :?:?: error: 'main' is not marked 'pub'
// :1:1: note: declared here
// :?:?: note: called from here

View File

@ -1,8 +0,0 @@
// error
// backend=stage1
// target=native
// output_mode=Exe
//
// error: root source file has no member called 'main'

View File

@ -1,9 +0,0 @@
fn main() void {}
// error
// backend=stage1
// target=native
// output_mode=Exe
//
// error: 'main' is private
// tmp.zig:1:1: note: declared here