From a99d2a5ad932f6d3808d1bd8895288e743d0ff22 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Wed, 22 Jul 2026 14:13:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=BA=86=20TPV=EF=BC=8C?= =?UTF-8?q?=E4=BD=BF=E5=85=B6=E8=83=BD=E5=A4=9F=E7=BC=96=E8=AF=91=20Test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/lib/core/Handles/HandlesFunctions.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/App/lib/core/Handles/HandlesFunctions.py b/App/lib/core/Handles/HandlesFunctions.py index 0a9449c..c19f159 100644 --- a/App/lib/core/Handles/HandlesFunctions.py +++ b/App/lib/core/Handles/HandlesFunctions.py @@ -470,6 +470,12 @@ def translate_function_def(trans: HT.Translator | t.CPtr, if is_extern_decl != 0: # 外部声明函数:生成 declare(仅声明,不定义) + # 先检查是否已由 forward_declare_functions 创建,避免重复 declare + existing_extern: llvmlite.Function | t.CPtr = HandlesExprCall.find_func_in_module(mod, mangled_name) + if existing_extern is not None: + # 已存在前向声明,复用之,不再重复创建 + return 0 + func: llvmlite.Function | t.CPtr = llvmlite.create_declare( pool, mod, mangled_name, ret_ty) if func is None: