diff --git a/App/lib/core/Gen/Stmt/StmtGenCifMixin.vp b/App/lib/core/Gen/Stmt/StmtGenCifMixin.vp index c7714c9..3689896 100644 --- a/App/lib/core/Gen/Stmt/StmtGenCifMixin.vp +++ b/App/lib/core/Gen/Stmt/StmtGenCifMixin.vp @@ -602,6 +602,18 @@ class StmtGenCifMixin: ret_ty_rt: llvmlite.LLVMType | t.CPtr = None if cur_func_rt is not None and val is not None and val.Ty is not None: ret_ty_rt = llvmlite.function_get_ret_ty(cur_func_rt) + # void 函数 return :丢弃值 + ret void(Python 语义合法;此前 + # 直接 build_ret(val) 生成 ret i32 与 define void 冲突 → llc "value + # doesn't match function result type 'void'"——GenApi.add_global_name + # `return g.TranslatorGen.add_global_name(...)` 委托调用根因)。 + if ret_ty_rt is not None and val is not None: + rv_void: int = 0 + match ret_ty_rt: + case llvmlite.LLVMType.Void(): + rv_void = 1 + if rv_void != 0: + llvmlite.build_ret_void(builder) + return 0 if ret_ty_rt is not None: val_bits: int = self.Gen.ExprGenBase.get_llvm_type_bits(val.Ty) ret_bits: int = self.Gen.ExprGenBase.get_llvm_type_bits(ret_ty_rt)