浏览代码

* give an error when trying to call through to a C varargs routine with a
high level code generator
o we cannot create a high-level stub in that case

git-svn-id: trunk@41443 -

Jonas Maebe 6 年之前
父节点
当前提交
bc77aad3d9
共有 4 个文件被更改,包括 394 次插入388 次删除
  1. 4 1
      compiler/msg/errore.msg
  2. 3 2
      compiler/msgidx.inc
  3. 379 384
      compiler/msgtxt.inc
  4. 8 1
      compiler/psub.pas

+ 4 - 1
compiler/msg/errore.msg

@@ -1594,7 +1594,10 @@ parser_e_only_static_members_via_object_type=03349_E_Only static methods and sta
 %   TObj.test;
 %   TObj.test;
 % \end{verbatim}
 % \end{verbatim}
 % \var{test} is not a static method and hence cannot be called through a type, but only using an instance.
 % \var{test} is not a static method and hence cannot be called through a type, but only using an instance.
-%
+parse_e_callthrough_varargs=03350_E_Cannot redeclare C-style variadic function "$1" as external on this platform; make its first declaration already external
+% If a function is declared normally in the interface or as a forward declaration, and then later as external, the compiler
+% must generate a stub that calls the external function. Due to code generation limitations, this cannot be done on some
+% platforms. Even on platforms where it is supported, this is quite inefficient.
 %
 %
 % \end{description}
 % \end{description}
 %
 %

+ 3 - 2
compiler/msgidx.inc

@@ -460,6 +460,7 @@ const
   parser_w_operator_overloaded_hidden_3=03347;
   parser_w_operator_overloaded_hidden_3=03347;
   parser_e_threadvar_must_be_class=03348;
   parser_e_threadvar_must_be_class=03348;
   parser_e_only_static_members_via_object_type=03349;
   parser_e_only_static_members_via_object_type=03349;
+  parse_e_callthrough_varargs=03350;
   type_e_mismatch=04000;
   type_e_mismatch=04000;
   type_e_incompatible_types=04001;
   type_e_incompatible_types=04001;
   type_e_not_equal_types=04002;
   type_e_not_equal_types=04002;
@@ -1107,9 +1108,9 @@ const
   option_info=11024;
   option_info=11024;
   option_help_pages=11025;
   option_help_pages=11025;
 
 
-  MsgTxtSize = 82796;
+  MsgTxtSize = 82926;
 
 
   MsgIdxMax : array[1..20] of longint=(
   MsgIdxMax : array[1..20] of longint=(
-    28,106,350,126,99,59,142,34,221,67,
+    28,106,351,126,99,59,142,34,221,67,
     62,20,30,1,1,1,1,1,1,1
     62,20,30,1,1,1,1,1,1,1
   );
   );

文件差异内容过多而无法显示
+ 379 - 384
compiler/msgtxt.inc


+ 8 - 1
compiler/psub.pas

@@ -2371,7 +2371,14 @@ implementation
                  if (not pd.forwarddef) and
                  if (not pd.forwarddef) and
                     (pd.hasforward) and
                     (pd.hasforward) and
                     (proc_get_importname(pd)<>'') then
                     (proc_get_importname(pd)<>'') then
-                   call_through_new_name(pd,proc_get_importname(pd))
+                   begin
+                     { we cannot handle the callee-side of variadic functions (and
+                       even if we could, e.g. LLVM cannot call through to something
+                       else in that case) }
+                     if is_c_variadic(pd) then
+                       Message1(parse_e_callthrough_varargs,pd.fullprocname(false));
+                     call_through_new_name(pd,proc_get_importname(pd));
+                   end
                  else
                  else
 {$endif cpuhighleveltarget}
 {$endif cpuhighleveltarget}
                    begin
                    begin

部分文件因为文件数量过多而无法显示