* implicitly convert constant string to stringdef if it is indexed

git-svn-id: trunk@1468 -
This commit is contained in:
peter 2005-10-18 10:52:43 +00:00
parent ea6dadb7be
commit 45fbeaad53

View File

@ -229,14 +229,16 @@ implementation
function tloadparentfpnode.det_resulttype:tnode; function tloadparentfpnode.det_resulttype:tnode;
{$ifdef dummy}
var var
currpi : tprocinfo; currpi : tprocinfo;
hsym : tparavarsym; hsym : tparavarsym;
{$endif dummy}
begin begin
result:=nil; result:=nil;
resulttype:=voidpointertype; resulttype:=voidpointertype;
{ {$ifdef dummy}
currently parentfps are never loaded in registers (FK) { currently parentfps are never loaded in registers (FK) }
if (current_procinfo.procdef.parast.symtablelevel<>parentpd.parast.symtablelevel) then if (current_procinfo.procdef.parast.symtablelevel<>parentpd.parast.symtablelevel) then
begin begin
@ -253,7 +255,7 @@ implementation
hsym.varregable:=vr_none; hsym.varregable:=vr_none;
end; end;
end; end;
} {$endif dummy}
end; end;
@ -638,6 +640,18 @@ implementation
result:=nil; result:=nil;
resulttypepass(left); resulttypepass(left);
resulttypepass(right); resulttypepass(right);
{ implicitly convert stringconstant to stringdef,
see tbs/tb0476.pp for a test }
if (left.nodetype=stringconstn) and
(tstringconstnode(left).st_type=st_conststring) then
begin
if tstringconstnode(left).len>255 then
inserttypeconv(left,cansistringtype)
else
inserttypeconv(left,cshortstringtype);
end;
{ In p[1] p is always valid, it is not possible to { In p[1] p is always valid, it is not possible to
declared a shortstring or normal array that has declared a shortstring or normal array that has
undefined number of elements. Dynamic array and undefined number of elements. Dynamic array and