mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-19 23:19:24 +02:00
+ stringvar[l..h] now valid parameter for open array of char.
git-svn-id: trunk@5038 -
This commit is contained in:
parent
068c0f7952
commit
de423ab5b0
@ -395,6 +395,9 @@ type
|
||||
right:=nil;
|
||||
end;
|
||||
temp.free;
|
||||
{Tree changed from p[l..h] to p[l], recalculate resulttype.}
|
||||
p.resulttype.def:=nil;
|
||||
resulttypepass(p);
|
||||
end
|
||||
else
|
||||
begin
|
||||
|
@ -660,7 +660,7 @@ implementation
|
||||
|
||||
function tvecnode.det_resulttype:tnode;
|
||||
var
|
||||
htype : ttype;
|
||||
htype,elementtype : ttype;
|
||||
valid : boolean;
|
||||
begin
|
||||
result:=nil;
|
||||
@ -745,21 +745,30 @@ implementation
|
||||
end;
|
||||
stringdef :
|
||||
begin
|
||||
{ indexed access to 0 element is only allowed for shortstrings }
|
||||
if (right.nodetype=ordconstn) and
|
||||
(tordconstnode(right).value=0) and
|
||||
not(is_shortstring(left.resulttype.def)) then
|
||||
CGMessage(cg_e_can_access_element_zero);
|
||||
case tstringdef(left.resulttype.def).string_typ of
|
||||
st_widestring :
|
||||
resulttype:=cwidechartype;
|
||||
st_ansistring :
|
||||
resulttype:=cchartype;
|
||||
st_longstring :
|
||||
resulttype:=cchartype;
|
||||
st_shortstring :
|
||||
resulttype:=cchartype;
|
||||
st_widestring :
|
||||
elementtype:=cwidechartype;
|
||||
st_ansistring :
|
||||
elementtype:=cchartype;
|
||||
st_longstring :
|
||||
elementtype:=cchartype;
|
||||
st_shortstring :
|
||||
elementtype:=cchartype;
|
||||
end;
|
||||
if right.nodetype=rangen then
|
||||
begin
|
||||
htype.setdef(Tarraydef.create_from_pointer(elementtype));
|
||||
resulttype:=htype;
|
||||
end
|
||||
else
|
||||
begin
|
||||
{ indexed access to 0 element is only allowed for shortstrings }
|
||||
if (right.nodetype=ordconstn) and
|
||||
(tordconstnode(right).value=0) and
|
||||
not is_shortstring(left.resulttype.def) then
|
||||
CGMessage(cg_e_can_access_element_zero);
|
||||
resulttype:=elementtype;
|
||||
end;
|
||||
end;
|
||||
variantdef :
|
||||
resulttype:=cvarianttype;
|
||||
|
@ -1869,6 +1869,9 @@ implementation
|
||||
stringdef :
|
||||
begin
|
||||
p2:=comp_expr(true);
|
||||
if try_to_consume(_POINTPOINT) then
|
||||
{ Support string[0..9] which returns array [0..9] of char.}
|
||||
p2:=crangenode.create(p2,comp_expr(true));
|
||||
p1:=cvecnode.create(p1,p2);
|
||||
end;
|
||||
arraydef,
|
||||
|
Loading…
Reference in New Issue
Block a user