Fix for Mantis #26271: Don't trash local variables that are used for the Default() intrinsic.

* ngenutil.pas, tnodeutils.trashable_sym:
    check for vo_is_default_var flag and don't consider such as trashable

+ added test

git-svn-id: trunk@27872 -
This commit is contained in:
svenbarth 2014-06-06 13:59:52 +00:00
parent a025a87c19
commit 4a0d27ebfe
3 changed files with 19 additions and 0 deletions

1
.gitattributes vendored
View File

@ -13944,6 +13944,7 @@ tests/webtbs/tw26226.pp -text svneol=native#text/plain
tests/webtbs/tw26230.pp svneol=native#text/plain
tests/webtbs/tw2626.pp svneol=native#text/plain
tests/webtbs/tw2627.pp svneol=native#text/plain
tests/webtbs/tw26271.pp svneol=native#text/pascal
tests/webtbs/tw2631.pp svneol=native#text/plain
tests/webtbs/tw26408.pp svneol=native#text/pascal
tests/webtbs/tw2643.pp svneol=native#text/plain

View File

@ -407,6 +407,7 @@ implementation
((p.typ=paravarsym) and
((vo_is_funcret in tabstractnormalvarsym(p).varoptions) or
(tabstractnormalvarsym(p).varspez=vs_out)))) and
not (vo_is_default_var in tabstractnormalvarsym(p).varoptions) and
not is_managed_type(tabstractnormalvarsym(p).vardef) and
not assigned(tabstractnormalvarsym(p).defaultconstsym);
end;

17
tests/webtbs/tw26271.pp Normal file
View File

@ -0,0 +1,17 @@
{ %NORUN }
{$MODE OBJFPC}
program tw26271;
type
TRecord = record
Member: Pointer;
end;
function TestFunction(): TRecord;
begin // test.pas(10,1) Error: Can't assign values to const variable
Result := Default(TRecord);
end;
begin
end.