+ initialise managed string function results with an error string when

compiling with -gt (mantis #28948)

git-svn-id: trunk@33198 -
This commit is contained in:
Jonas Maebe 2016-03-06 17:22:11 +00:00
parent 3499c59872
commit 0e97811b50
3 changed files with 30 additions and 2 deletions

1
.gitattributes vendored
View File

@ -14927,6 +14927,7 @@ tests/webtbs/tw2891.pp svneol=native#text/plain
tests/webtbs/tw28916.pp svneol=native#text/pascal
tests/webtbs/tw2892.pp svneol=native#text/plain
tests/webtbs/tw28934.pp svneol=native#text/plain
tests/webtbs/tw28948.pp svneol=native#text/plain
tests/webtbs/tw28964.pp svneol=native#text/plain
tests/webtbs/tw2897.pp svneol=native#text/plain
tests/webtbs/tw2899.pp svneol=native#text/plain

View File

@ -443,7 +443,11 @@ implementation
((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 is_managed_type(tabstractnormalvarsym(p).vardef) or
(is_string(tabstractnormalvarsym(p).vardef) and
(vo_is_funcret in tabstractnormalvarsym(p).varoptions)
)
) and
not assigned(tabstractnormalvarsym(p).defaultconstsym);
end;
@ -468,7 +472,19 @@ implementation
the procedure address -> cast to tmethod instead }
trashn:=ctypeconvnode.create_explicit(trashn,methodpointertype);
end;
if ((p.typ=localvarsym) and
if is_managed_type(p.vardef) then
begin
if is_string(p.vardef) then
trash_small(stat,trashn,
cstringconstnode.createstr(
'uninitialized function result in '+
tprocdef(p.owner.defowner).customprocname([pno_proctypeoption, pno_paranames,pno_ownername, pno_noclassmarker])
)
)
else
internalerror(2016030601);
end
else if ((p.typ=localvarsym) and
(not(vo_is_funcret in p.varoptions) or
not is_shortstring(p.vardef))) or
((p.typ=paravarsym) and

11
tests/webtbs/tw28948.pp Normal file
View File

@ -0,0 +1,11 @@
{ %OPT=-gt }
function f: ansistring;
begin
end;
begin
writeln(f);
if pos('uninitialized function result',f)=0 then
halt(1);
end.