Bläddra i källkod

* fixed node complexity calculation for certain inlinenodes
(mantis 12404)

git-svn-id: trunk@12020 -

Jonas Maebe 16 år sedan
förälder
incheckning
7f8e9b8d35
3 ändrade filer med 45 tillägg och 2 borttagningar
  1. 1 0
      .gitattributes
  2. 4 2
      compiler/nutils.pas
  3. 40 0
      tests/webtbs/tw12404.pp

+ 1 - 0
.gitattributes

@@ -8604,6 +8604,7 @@ tests/webtbs/tw12242.pp svneol=native#text/plain
 tests/webtbs/tw12249.pp svneol=native#text/plain
 tests/webtbs/tw1228.pp svneol=native#text/plain
 tests/webtbs/tw1229.pp svneol=native#text/plain
+tests/webtbs/tw12404.pp svneol=native#text/plain
 tests/webtbs/tw1250.pp svneol=native#text/plain
 tests/webtbs/tw12508a.pp svneol=native#text/plain
 tests/webtbs/tw1251b.pp svneol=native#text/plain

+ 4 - 2
compiler/nutils.pas

@@ -798,13 +798,15 @@ implementation
                         { operation (add, sub, or, and }
                         inc(result);
                         { left expression }
-                        inc(result,node_complexity(tbinarynode(p).left));
+                        inc(result,node_complexity(tcallparanode(tunarynode(p).left).left));
                         if (result >= NODE_COMPLEXITY_INF) then
                           begin
                             result := NODE_COMPLEXITY_INF;
                             exit;
                           end;
-                        p := tbinarynode(p).right;
+                        p:=tcallparanode(tunarynode(p).left).right;
+                        if assigned(p) then
+                          p:=tcallparanode(p).left;
                       end;
                     else
                       begin

+ 40 - 0
tests/webtbs/tw12404.pp

@@ -0,0 +1,40 @@
+{ %norun }
+
+{$mode objfpc}
+{$h+}
+{$inline on}
+unit tw12404;
+
+interface
+
+Type
+  TMyClass = Class(TObject)
+  Private
+    FPos : integer;
+    FChar : PChar;
+    Function MyFunc : Char; inline;
+    Function MyOtherFunction : Integer;
+  end;
+
+implementation
+
+Function TMyClass.MyFunc : Char; inline;
+
+begin
+  Inc(FPos);
+  Inc(FChar);
+  Result:=FChar^;
+end;
+
+Function TMyClass.MyOtherFunction : Integer;
+
+Var
+  C : Char;
+
+begin
+  C:=MyFunc;
+end;
+
+end.
+
+