diff options
author | florian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2018-11-03 17:31:10 +0000 |
---|---|---|
committer | florian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2018-11-03 17:31:10 +0000 |
commit | 578f65bb207ad1924bcbcb8026f84f949d302467 (patch) | |
tree | 9b37f08bcc4024b20d0dcf4d8c86fcff5d2c66f1 | |
parent | cb8f2c45afc75170fae439cc3f3a697b037e370f (diff) | |
download | fpc-578f65bb207ad1924bcbcb8026f84f949d302467.tar.gz |
* wrapcomplexinlinepara takes care of function results which need different temp. handling, resolves #34438
* tw34438 failed with -O3, fixes also dfa for inline functions returning results as "complex" parameter
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@40202 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r-- | compiler/ncal.pas | 9 | ||||
-rw-r--r-- | compiler/optdfa.pas | 1 | ||||
-rw-r--r-- | tests/webtbs/tw34438.pp | 42 |
3 files changed, 51 insertions, 1 deletions
diff --git a/compiler/ncal.pas b/compiler/ncal.pas index 9fb160108b..f5e1042064 100644 --- a/compiler/ncal.pas +++ b/compiler/ncal.pas @@ -4832,11 +4832,16 @@ implementation ptrtype: tdef; tempnode: ttempcreatenode; paraaddr: taddrnode; + isfuncretnode : boolean; begin ptrtype:=cpointerdef.getreusable(para.left.resultdef); tempnode:=ctempcreatenode.create(ptrtype,ptrtype.size,tt_persistent,true); addstatement(inlineinitstatement,tempnode); - addstatement(inlinecleanupstatement,ctempdeletenode.create(tempnode)); + isfuncretnode:=nf_is_funcret in para.left.flags; + if isfuncretnode then + addstatement(inlinecleanupstatement,ctempdeletenode.create_normal_temp(tempnode)) + else + addstatement(inlinecleanupstatement,ctempdeletenode.create(tempnode)); { inherit addr_taken flag } if (tabstractvarsym(para.parasym).addr_taken) then tempnode.includetempflag(ti_addr_taken); @@ -4848,6 +4853,8 @@ implementation addstatement(inlineinitstatement,cassignmentnode.create(ctemprefnode.create(tempnode), paraaddr)); para.left:=cderefnode.create(ctemprefnode.create(tempnode)); + if isfuncretnode then + Include(para.left.flags,nf_is_funcret); end; diff --git a/compiler/optdfa.pas b/compiler/optdfa.pas index a7950f3068..1d450413a0 100644 --- a/compiler/optdfa.pas +++ b/compiler/optdfa.pas @@ -383,6 +383,7 @@ unit optdfa; temprefn, loadn, typeconvn, + derefn, assignn: begin if not(assigned(node.optinfo^.def)) and diff --git a/tests/webtbs/tw34438.pp b/tests/webtbs/tw34438.pp new file mode 100644 index 0000000000..08e3743660 --- /dev/null +++ b/tests/webtbs/tw34438.pp @@ -0,0 +1,42 @@ +{%norun} +{$mode objfpc} +uses + types,math; + +type + PGtkWidget = pointer; + PGtkNotebook = pointer; + +function MyRect(Left,Top,Right,Bottom : Integer) : TRect; inline; + +begin + MyRect.Left:=Left; + MyRect.Top:=Top; + MyRect.Right:=Right; + MyRect.Bottom:=Bottom; +end; + +function GetWidgetClientRect(TheWidget: PGtkWidget): TRect; +var + Widget, ClientWidget: PGtkWidget; + AChild: PGtkWidget; + + procedure GetNoteBookClientRect(NBWidget: PGtkNotebook); + var + PageIndex: LongInt; + PageWidget: PGtkWidget; + FrameBorders: TRect; + aWidth: LongInt; + aHeight: LongInt; + begin + Result:=MyRect(0,0, + Max(0,AWidth-FrameBorders.Left-FrameBorders.Right), + Max(0,aHeight-FrameBorders.Top-FrameBorders.Bottom)); + end; + +begin +end; + + +begin +end. |