mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-10 09:29:13 +02:00
* don't allow pointer indexing in non-fpc modes
* array type required message instead of type mismatch (merged)
This commit is contained in:
parent
8bd87aafd6
commit
d3aa211230
@ -482,18 +482,21 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{ are we accessing a pointer[], then convert the pointer to
|
{ are we accessing a pointer[], then convert the pointer to
|
||||||
an array first }
|
an array first, in FPC this is allowed for all pointers in
|
||||||
if (p^.left^.resulttype^.deftype=pointerdef) then
|
delphi/tp7 it's only allowed for pchars }
|
||||||
begin
|
if (p^.left^.resulttype^.deftype=pointerdef) and
|
||||||
{ convert pointer to array }
|
((m_fpc in aktmodeswitches) or
|
||||||
harr:=new(parraydef,init(0,$7fffffff,s32bitdef));
|
is_pchar(p^.left^.resulttype)) then
|
||||||
parraydef(harr)^.elementtype.def:=ppointerdef(p^.left^.resulttype)^.pointertype.def;
|
begin
|
||||||
p^.left:=gentypeconvnode(p^.left,harr);
|
{ convert pointer to array }
|
||||||
firstpass(p^.left);
|
harr:=new(parraydef,init(0,$7fffffff,s32bitdef));
|
||||||
if codegenerror then
|
parraydef(harr)^.elementtype.def:=ppointerdef(p^.left^.resulttype)^.pointertype.def;
|
||||||
exit;
|
p^.left:=gentypeconvnode(p^.left,harr);
|
||||||
p^.resulttype:=parraydef(harr)^.elementtype.def
|
firstpass(p^.left);
|
||||||
end;
|
if codegenerror then
|
||||||
|
exit;
|
||||||
|
p^.resulttype:=parraydef(harr)^.elementtype.def
|
||||||
|
end;
|
||||||
|
|
||||||
{ determine return type }
|
{ determine return type }
|
||||||
if not assigned(p^.resulttype) then
|
if not assigned(p^.resulttype) then
|
||||||
@ -512,7 +515,8 @@ implementation
|
|||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
CGMessage(type_e_mismatch);
|
CGMessage(type_e_array_required);
|
||||||
|
|
||||||
{ the register calculation is easy if a const index is used }
|
{ the register calculation is easy if a const index is used }
|
||||||
if p^.right^.treetype=ordconstn then
|
if p^.right^.treetype=ordconstn then
|
||||||
begin
|
begin
|
||||||
@ -639,7 +643,11 @@ implementation
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.5 2000-08-04 22:00:52 peter
|
Revision 1.6 2000-08-20 15:05:45 peter
|
||||||
|
* don't allow pointer indexing in non-fpc modes
|
||||||
|
* array type required message instead of type mismatch (merged)
|
||||||
|
|
||||||
|
Revision 1.5 2000/08/04 22:00:52 peter
|
||||||
* merges from fixes
|
* merges from fixes
|
||||||
|
|
||||||
Revision 1.4 2000/08/02 19:49:59 peter
|
Revision 1.4 2000/08/02 19:49:59 peter
|
||||||
|
Loading…
Reference in New Issue
Block a user