Explorar o código

* fixed some voidpointerdef handling

git-svn-id: branches/jvmbackend@18584 -
Jonas Maebe %!s(int64=14) %!d(string=hai) anos
pai
achega
0fad10179c
Modificáronse 3 ficheiros con 17 adicións e 4 borrados
  1. 3 1
      compiler/jvm/hlcgcpu.pas
  2. 9 0
      compiler/jvm/njvmcnv.pas
  3. 5 3
      compiler/jvm/njvmmem.pas

+ 3 - 1
compiler/jvm/hlcgcpu.pas

@@ -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;

+ 9 - 0
compiler/jvm/njvmcnv.pas

@@ -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

+ 5 - 3
compiler/jvm/njvmmem.pas

@@ -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 }