* fixed some voidpointerdef handling

git-svn-id: branches/jvmbackend@18584 -
This commit is contained in:
Jonas Maebe 2011-08-20 08:12:39 +00:00
parent ba5e264a93
commit 0fad10179c
3 changed files with 17 additions and 4 deletions

View File

@ -259,7 +259,9 @@ implementation
else
result:=R_ADDRESSREGISTER;
{ shortstrings are implemented via classes }
else if is_shortstring(def) then
else if is_shortstring(def) or
{ voiddef can only be typecasted into (implicit) pointers }
is_void(def) then
result:=R_ADDRESSREGISTER
else
result:=inherited;

View File

@ -644,6 +644,15 @@ implementation
((resultdef.typ in [stringdef,classrefdef]) and
not is_shortstring(resultdef)) or
procvarconv;
{ typescasts from void (the result of untyped_ptr^) to an implicit
pointertype (record, array, ...) also needs a typecheck }
if is_void(left.resultdef) and
jvmimplicitpointertype(resultdef) then
begin
fromclasscompatible:=true;
toclasscompatible:=true;
end;
if fromclasscompatible and toclasscompatible then
begin
{ we need an as-node to check the validity of the conversion (since

View File

@ -73,7 +73,8 @@ implementation
begin
result:=inherited;
if not(left.resultdef.typ=pointerdef) or
not jvmimplicitpointertype(tpointerdef(left.resultdef).pointeddef) then
((left.resultdef<>voidpointertype) and
not jvmimplicitpointertype(tpointerdef(left.resultdef).pointeddef)) then
begin
CGMessage(parser_e_illegal_expression);
exit
@ -83,8 +84,9 @@ implementation
procedure tjvmderefnode.pass_generate_code;
begin
secondpass(left);
if (left.resultdef.typ=pointerdef) or
jvmimplicitpointertype(left.resultdef) then
if (left.resultdef.typ=pointerdef) and
((left.resultdef=voidpointertype) or
jvmimplicitpointertype(tpointerdef(left.resultdef).pointeddef)) then
begin
{ this is basically a typecast: the left node is a regular
'pointer', and we typecast it to an implicit pointer }