فهرست منبع

* call FreeInstance after fail if vmt<>nil rather than if vmt=1
(mantis #10790)

git-svn-id: trunk@10249 -

Jonas Maebe 17 سال پیش
والد
کامیت
c44fb4a79e
3فایلهای تغییر یافته به همراه30 افزوده شده و 6 حذف شده
  1. 1 0
      .gitattributes
  2. 4 6
      compiler/nutils.pas
  3. 25 0
      tests/webtbs/tw10790.pp

+ 1 - 0
.gitattributes

@@ -7965,6 +7965,7 @@ tests/webtbs/tw10736.pp svneol=native#text/plain
 tests/webtbs/tw10753.pp svneol=native#text/plain
 tests/webtbs/tw10753a.pp svneol=native#text/plain
 tests/webtbs/tw10757.pp svneol=native#text/plain
+tests/webtbs/tw10790.pp svneol=native#text/plain
 tests/webtbs/tw1081.pp svneol=native#text/plain
 tests/webtbs/tw1090.pp svneol=native#text/plain
 tests/webtbs/tw1092.pp svneol=native#text/plain

+ 4 - 6
compiler/nutils.pas

@@ -471,17 +471,15 @@ implementation
             if assigned(srsym) and
                (srsym.typ=procsym) then
               begin
-                { if self<>0 and vmt=1 then freeinstance }
+                { if self<>0 and vmt<>0 then freeinstance }
                 addstatement(newstatement,cifnode.create(
                     caddnode.create(andn,
                         caddnode.create(unequaln,
                             load_self_pointer_node,
                             cnilnode.create),
-                        caddnode.create(equaln,
-                            ctypeconvnode.create(
-                                load_vmt_pointer_node,
-                                voidpointertype),
-                            cpointerconstnode.create(1,voidpointertype))),
+                        caddnode.create(unequaln,
+                            load_vmt_pointer_node,
+                            cnilnode.create)),
                     ccallnode.create(nil,tprocsym(srsym),srsym.owner,load_self_node,[]),
                     nil));
               end

+ 25 - 0
tests/webtbs/tw10790.pp

@@ -0,0 +1,25 @@
+{ %OPT=-gh }
+
+{$ifdef fpc}
+{$mode delphi}
+{$endif}
+
+program failtest;
+
+type
+   TMyClass = class
+      constructor Create;
+   end;
+    
+constructor TMyClass.Create;
+begin
+   Fail;
+end;
+
+var
+   MyClass : TMyClass;
+
+begin
+   HaltOnNotReleased := true;
+   MyClass := TMyClass.Create;
+end.