mirror of
https://github.com/ziglang/zig.git
synced 2026-01-04 04:25:05 +00:00
Sema: avoid analyzing functions which failed when inlining
This commit is contained in:
parent
e6588857df
commit
886fa455fa
@ -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
|
||||
|
||||
@ -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
|
||||
10
test/cases/compile_errors/private_main_fn.zig
Normal file
10
test/cases/compile_errors/private_main_fn.zig
Normal 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
|
||||
@ -1,8 +0,0 @@
|
||||
|
||||
|
||||
// error
|
||||
// backend=stage1
|
||||
// target=native
|
||||
// output_mode=Exe
|
||||
//
|
||||
// error: root source file has no member called 'main'
|
||||
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user