Browse Source

* string constants have a size of 0, resolves #38504

git-svn-id: trunk@48759 -
florian 4 years ago
parent
commit
60c8b71bae

+ 2 - 0
.gitattributes

@@ -16724,6 +16724,8 @@ tests/webtbf/tw38287.pp svneol=native#text/pascal
 tests/webtbf/tw38289a.pp svneol=native#text/pascal
 tests/webtbf/tw38289b.pp svneol=native#text/pascal
 tests/webtbf/tw38439.pp svneol=native#text/pascal
+tests/webtbf/tw38504.pp svneol=native#text/pascal
+tests/webtbf/tw38504b.pp svneol=native#text/pascal
 tests/webtbf/tw3930a.pp svneol=native#text/plain
 tests/webtbf/tw3931b.pp svneol=native#text/plain
 tests/webtbf/tw3969.pp svneol=native#text/plain

+ 3 - 7
compiler/ncon.pas

@@ -948,20 +948,15 @@ implementation
          dogetcopy:=n;
       end;
 
+
     function tstringconstnode.pass_typecheck:tnode;
-      var
-        l : aint;
       begin
         result:=nil;
         case cst_type of
           cst_conststring :
             begin
               { handle and store as array[0..len-1] of char }
-              if len>0 then
-                l:=len-1
-              else
-                l:=0;
-              resultdef:=carraydef.create(0,l,s32inttype);
+              resultdef:=carraydef.create(0,len-1,s32inttype);
               tarraydef(resultdef).elementdef:=cansichartype;
               include(tarraydef(resultdef).arrayoptions,ado_IsConstString);
             end;
@@ -981,6 +976,7 @@ implementation
         end;
       end;
 
+
     function tstringconstnode.pass_1 : tnode;
       begin
         result:=nil;

+ 1 - 1
packages/fcl-db/src/export/fpxmlxsdexport.pp

@@ -2990,7 +2990,7 @@ begin
   }
 
   CreateXSD := True;
-  DecimalSeparator := char(''); //Don't override decimal separator by default
+  DecimalSeparator := #0; //Don't override decimal separator by default
 
   if Source is TXMLXSDFormatSettings then
   begin

+ 11 - 0
tests/webtbf/tw38504.pp

@@ -0,0 +1,11 @@
+{ %fail }
+Var
+  MyVar : char;
+
+Procedure MyProc;
+Begin
+  MyVar := ''; (* <-- two single-quotes *)
+End;
+
+Begin
+End.

+ 11 - 0
tests/webtbf/tw38504b.pp

@@ -0,0 +1,11 @@
+{ %fail }
+Var
+  MyVar : char;
+
+Procedure MyProc;
+Begin
+  MyVar := char('');
+End;
+
+Begin
+End.