Skip to content

Commit 886fa45

Browse files
committed
Sema: avoid analyzing functions which failed when inlining
1 parent e658885 commit 886fa45

5 files changed

Lines changed: 23 additions & 17 deletions

File tree

src/Sema.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,6 +2257,9 @@ fn failWithOwnedErrorMsg(sema: *Sema, err_msg: *Module.ErrorMsg) CompileError {
22572257
sema.owner_decl.analysis = .sema_failure;
22582258
sema.owner_decl.generation = mod.generation;
22592259
}
2260+
if (sema.func) |func| {
2261+
func.state = .sema_failure;
2262+
}
22602263
const gop = mod.failed_decls.getOrPutAssumeCapacity(sema.owner_decl_index);
22612264
if (gop.found_existing) {
22622265
// If there are multiple errors for the same Decl, prefer the first one added.
@@ -6385,6 +6388,7 @@ fn analyzeCall(
63856388
}),
63866389
else => unreachable,
63876390
};
6391+
if (!is_comptime_call and module_fn.state == .sema_failure) return error.AnalysisFail;
63886392

63896393
// Analyze the ZIR. The same ZIR gets analyzed into a runtime function
63906394
// or an inlined call depending on what union tag the `label` field is
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
3+
// error
4+
// backend=llvm
5+
// target=x86_64-linux
6+
// output_mode=Exe
7+
//
8+
// :?:?: error: root struct of file 'tmp' has no member named 'main'
9+
// :?:?: note: called from here
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
fn main() void {}
2+
3+
// error
4+
// backend=llvm
5+
// target=x86_64-linux
6+
// output_mode=Exe
7+
//
8+
// :?:?: error: 'main' is not marked 'pub'
9+
// :1:1: note: declared here
10+
// :?:?: note: called from here

test/cases/compile_errors/stage1/exe/missing_main_fn_in_executable.zig

Lines changed: 0 additions & 8 deletions
This file was deleted.

test/cases/compile_errors/stage1/exe/private_main_fn.zig

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)