Browse Source

* implicitly convert constant string to stringdef if it is indexed

git-svn-id: trunk@1468 -
peter 20 years ago
parent
commit
45fbeaad53
1 changed files with 17 additions and 3 deletions
  1. 17 3
      compiler/nmem.pas

+ 17 - 3
compiler/nmem.pas

@@ -229,14 +229,16 @@ implementation
 
 
 
 
     function tloadparentfpnode.det_resulttype:tnode;
     function tloadparentfpnode.det_resulttype:tnode;
+{$ifdef dummy}
       var
       var
         currpi : tprocinfo;
         currpi : tprocinfo;
         hsym   : tparavarsym;
         hsym   : tparavarsym;
+{$endif dummy}
       begin
       begin
         result:=nil;
         result:=nil;
         resulttype:=voidpointertype;
         resulttype:=voidpointertype;
-        {
-          currently parentfps are never loaded in registers (FK)
+{$ifdef dummy}
+        { currently parentfps are never loaded in registers (FK) }
 
 
         if (current_procinfo.procdef.parast.symtablelevel<>parentpd.parast.symtablelevel) then
         if (current_procinfo.procdef.parast.symtablelevel<>parentpd.parast.symtablelevel) then
           begin
           begin
@@ -253,7 +255,7 @@ implementation
                 hsym.varregable:=vr_none;
                 hsym.varregable:=vr_none;
               end;
               end;
           end;
           end;
-        }
+{$endif dummy}
       end;
       end;
 
 
 
 
@@ -638,6 +640,18 @@ implementation
          result:=nil;
          result:=nil;
          resulttypepass(left);
          resulttypepass(left);
          resulttypepass(right);
          resulttypepass(right);
+
+         { implicitly convert stringconstant to stringdef,
+           see tbs/tb0476.pp for a test }
+         if (left.nodetype=stringconstn) and
+            (tstringconstnode(left).st_type=st_conststring) then
+           begin
+             if tstringconstnode(left).len>255 then
+               inserttypeconv(left,cansistringtype)
+             else
+               inserttypeconv(left,cshortstringtype);
+           end;
+
          { In p[1] p is always valid, it is not possible to
          { In p[1] p is always valid, it is not possible to
            declared a shortstring or normal array that has
            declared a shortstring or normal array that has
            undefined number of elements. Dynamic array and
            undefined number of elements. Dynamic array and