瀏覽代碼

* inline nodes can specify whether their result needs to be used

Sven/Sarah Barth 7 月之前
父節點
當前提交
2390e70a4e
共有 2 個文件被更改,包括 18 次插入2 次删除
  1. 16 0
      compiler/ninl.pas
  2. 2 2
      compiler/pstatmnt.pas

+ 16 - 0
compiler/ninl.pas

@@ -63,6 +63,8 @@ interface
           property parameters : tnode read left write left;
 
           function may_have_sideeffect_norecurse: boolean;
+
+          function may_ignore_result:boolean;
          protected
           { All the following routines currently
             call compilerprocs, unless they are
@@ -6051,6 +6053,20 @@ implementation
        end;
 
 
+     function tinlinenode.may_ignore_result:boolean;
+       begin
+         case inlinenumber of
+           in_atomic_inc,
+           in_atomic_dec,
+           in_atomic_xchg,
+           in_atomic_cmp_xchg:
+             result:=true;
+           else
+             result:=is_void(resultdef);
+         end;
+       end;
+
+
      function tinlinenode.first_fma: tnode;
        begin
          CGMessage1(cg_e_function_not_support_by_selected_instruction_set,'FMA');

+ 2 - 2
compiler/pstatmnt.pas

@@ -50,7 +50,7 @@ implementation
        paramgr,
        { pass 1 }
        pass_1,htypechk,
-       nutils,ngenutil,nbas,ncal,nmem,nset,ncnv,ncon,nld,nflw,
+       nutils,ngenutil,nbas,ncal,nmem,nset,ncnv,ncon,nld,nflw,ninl,
        { parser }
        scanner,
        pbase,ptype,pexpr,
@@ -1512,7 +1512,7 @@ implementation
              if not(p.nodetype in [nothingn,errorn,calln,ifn,assignn,breakn,inlinen,
                                    continuen,labeln,blockn,exitn,goton]) or
                 ((p.nodetype=inlinen) and
-                 not is_void(p.resultdef)) or
+                 not tinlinenode(p).may_ignore_result) or
                 ((p.nodetype=calln) and
                  (assigned(tcallnode(p).procdefinition)) and
                  (tcallnode(p).procdefinition.proctypeoption=potype_operator)) then