Browse Source

* support constant array of char to array of widechar

git-svn-id: trunk@1475 -
peter 20 years ago
parent
commit
8b60dbe4cb
1 changed files with 12 additions and 6 deletions
  1. 12 6
      compiler/ncnv.pas

+ 12 - 6
compiler/ncnv.pas

@@ -716,15 +716,21 @@ implementation
         if (left.nodetype = stringconstn) and
            (tstringdef(left.resulttype.def).string_typ=st_conststring) then
            begin
-             { if the array is large enough we can use the string
+             { if the array of char is large enough we can use the string
                constant directly. This is handled in ncgcnv }
-             if arrsize>=tstringconstnode(left).len then
+             if (arrsize>=tstringconstnode(left).len) and
+                is_char(tarraydef(resulttype.def).elementtype.def) then
                exit;
-             { Convert to shortstring/ansistring and call helper }
-             if tstringconstnode(left).len>255 then
-               inserttypeconv(left,cansistringtype)
+             { Convert to wide/short/ansistring and call default helper }
+             if is_widechar(tarraydef(resulttype.def).elementtype.def) then
+               inserttypeconv(left,cwidestringtype)
              else
-               inserttypeconv(left,cshortstringtype);
+               begin
+                 if tstringconstnode(left).len>255 then
+                   inserttypeconv(left,cansistringtype)
+                 else
+                   inserttypeconv(left,cshortstringtype);
+               end;
            end;
         if is_widechar(tarraydef(resulttype.def).elementtype.def) then
           chartype:='widechar'