浏览代码

* give an error when trying to typecast a unicodestring into a pwidechar
on the JVM target (we can't access the characters of a JLString as an
array)

git-svn-id: branches/jvmbackend@18769 -

Jonas Maebe 14 年之前
父节点
当前提交
d7cff1cd31
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      compiler/jvm/njvmcnv.pas

+ 9 - 0
compiler/jvm/njvmcnv.pas

@@ -457,6 +457,15 @@ implementation
       var
         ps: tsym;
       begin
+        { also called for unicodestring->pwidechar, not supported since we can't
+          directly access the characters in java.lang.String }
+        if not is_ansistring(left.resultdef) or
+           not is_pchar(resultdef) then
+          begin
+            CGMessage2(type_e_illegal_type_conversion,left.resultdef.typename,resultdef.typename);
+            result:=nil;
+            exit;
+          end;
         result:=ctypeconvnode.create_explicit(left,java_ansistring);
         ps:=search_struct_member(java_ansistring,'INTERNCHARS');
         if not assigned(ps) or