瀏覽代碼

Merged revisions 10473,10475 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

........
r10473 | peter | 2008-03-11 18:57:24 +0100 (Tue, 11 Mar 2008) | 3 lines

* give warning for disabling inline if assembler
is detected
........
r10475 | jonas | 2008-03-12 11:48:19 +0100 (Wed, 12 Mar 2008) | 2 lines

* fixed "array of const" check in r10473 (+ fixed indentation)
........

git-svn-id: branches/fixes_2_2@10539 -

peter 17 年之前
父節點
當前提交
5da1a86d94
共有 2 個文件被更改,包括 37 次插入41 次删除
  1. 1 32
      compiler/pdecsub.pas
  2. 36 9
      compiler/psub.pas

+ 1 - 32
compiler/pdecsub.pas

@@ -341,31 +341,6 @@ implementation
       end;
 
 
-    procedure check_inline_para(p:TObject;arg:pointer);
-      var
-        pd : tabstractprocdef absolute arg;
-      begin
-        if not(po_inline in pd.procoptions) or
-           (tsym(p).typ<>paravarsym) then
-         exit;
-        with tparavarsym(p) do
-         begin
-           case vardef.typ of
-             arraydef :
-               begin
-                 if is_array_constructor(vardef) or
-                    is_variant_array(vardef) then
-                   begin
-                     Message1(parser_w_not_supported_for_inline,'array of const');
-                     Message(parser_w_inlining_disabled);
-                     pd.proccalloption:=pocall_default;
-                   end;
-               end;
-           end;
-         end;
-      end;
-
-
     procedure set_addr_param_regable(p:TObject;arg:pointer);
       begin
         if (tsym(p).typ<>paravarsym) then
@@ -1200,12 +1175,6 @@ begin
 end;
 
 
-procedure pd_inline(pd:tabstractprocdef);
-begin
-  { Check if there are parameters that can't be inlined }
-  pd.parast.SymList.ForEachCall(@check_inline_para,pd);
-end;
-
 procedure pd_internconst(pd:tabstractprocdef);
 begin
   if pd.typ<>procdef then
@@ -1730,7 +1699,7 @@ const
     ),(
       idtok:_INLINE;
       pd_flags : [pd_interface,pd_implemen,pd_body,pd_notobjintf];
-      handler  : @pd_inline;
+      handler  : nil;
       pocall   : pocall_none;
       pooption : [po_inline];
       mutexclpocall : [];

+ 36 - 9
compiler/psub.pas

@@ -1177,18 +1177,45 @@ implementation
       begin
         result := false;
         if (pi_has_assembler_block in current_procinfo.flags) then
-          exit;
+          begin
+            Message1(parser_w_not_supported_for_inline,'assembler');
+            Message(parser_w_inlining_disabled);
+            exit;
+          end;
         for i:=0 to procdef.paras.count-1 do
           begin
             currpara:=tparavarsym(procdef.paras[i]);
-            { we can't handle formaldefs and special arrays (the latter may need a    }
-            { re-basing of the index, i.e. if you pass an array[1..10] as open array, }
-            { you have to add 1 to all index operations if you directly inline it     }
-            if ((currpara.varspez in [vs_out,vs_var,vs_const]) and
-                (currpara.vardef.typ=formaldef)) or
-               is_special_array(currpara.vardef)  then
-              exit;
-          end;
+            case currpara.vardef.typ of
+              formaldef :
+                begin
+                  if (currpara.varspez in [vs_out,vs_var,vs_const]) then
+                    begin
+                      Message1(parser_w_not_supported_for_inline,'formal parameter');
+                      Message(parser_w_inlining_disabled);
+                      exit;
+                    end;
+                end;
+              arraydef :
+                begin
+                  if is_array_of_const(currpara.vardef) or
+                     is_variant_array(currpara.vardef) then
+                    begin
+                      Message1(parser_w_not_supported_for_inline,'array of const');
+                      Message(parser_w_inlining_disabled);
+                      exit;
+                    end;
+                  { open arrays might need re-basing of the index, i.e. if you pass
+                    an array[1..10] as open array, you have to add 1 to all index operations
+                    if you directly inline it }
+                  if is_open_array(currpara.vardef) then
+                    begin
+                      Message1(parser_w_not_supported_for_inline,'open array');
+                      Message(parser_w_inlining_disabled);
+                      exit;
+                    end;
+                end;
+            end;
+        end;
         result:=true;
       end;