Browse Source

* string constants passed to array of const should be passed as ansistrings

git-svn-id: trunk@2523 -
florian 19 years ago
parent
commit
bbd3e2e391
1 changed files with 38 additions and 35 deletions
  1. 38 35
      compiler/nld.pas

+ 38 - 35
compiler/nld.pas

@@ -927,43 +927,46 @@ implementation
               { Insert typeconvs for array of const }
               { Insert typeconvs for array of const }
               if dovariant then
               if dovariant then
                begin
                begin
-                 case hp.left.resulttype.def.deftype of
-                   enumdef :
-                     hp.left:=ctypeconvnode.create_internal(hp.left,s32inttype);
-                   arraydef :
-                     begin
-                       if is_chararray(hp.left.resulttype.def) then
-                         hp.left:=ctypeconvnode.create_internal(hp.left,charpointertype)
-                       else
-                         if is_widechararray(hp.left.resulttype.def) then
-                           hp.left:=ctypeconvnode.create_internal(hp.left,widecharpointertype)
-                       else
-                         CGMessagePos1(hp.left.fileinfo,type_e_wrong_type_in_array_constructor,hp.left.resulttype.def.typename);
-                     end;
-                   orddef :
-                     begin
-                       if is_integer(hp.left.resulttype.def) and
-                          not(is_64bitint(hp.left.resulttype.def)) then
-                         hp.left:=ctypeconvnode.create(hp.left,s32inttype)
-                       else if is_void(hp.left.resulttype.def) then
+                 if hp.left.nodetype=stringconstn then
+                   hp.left:=ctypeconvnode.create_internal(hp.left,cansistringtype)
+                 else
+                   case hp.left.resulttype.def.deftype of
+                     enumdef :
+                       hp.left:=ctypeconvnode.create_internal(hp.left,s32inttype);
+                     arraydef :
+                       begin
+                         if is_chararray(hp.left.resulttype.def) then
+                           hp.left:=ctypeconvnode.create_internal(hp.left,charpointertype)
+                         else
+                           if is_widechararray(hp.left.resulttype.def) then
+                             hp.left:=ctypeconvnode.create_internal(hp.left,widecharpointertype)
+                         else
+                           CGMessagePos1(hp.left.fileinfo,type_e_wrong_type_in_array_constructor,hp.left.resulttype.def.typename);
+                       end;
+                     orddef :
+                       begin
+                         if is_integer(hp.left.resulttype.def) and
+                            not(is_64bitint(hp.left.resulttype.def)) then
+                           hp.left:=ctypeconvnode.create(hp.left,s32inttype)
+                         else if is_void(hp.left.resulttype.def) then
+                           CGMessagePos1(hp.left.fileinfo,type_e_wrong_type_in_array_constructor,hp.left.resulttype.def.typename);
+                       end;
+                     floatdef :
+                       if not(is_currency(hp.left.resulttype.def)) then
+                         hp.left:=ctypeconvnode.create(hp.left,pbestrealtype^);
+                     procvardef :
+                       hp.left:=ctypeconvnode.create(hp.left,voidpointertype);
+                     stringdef,
+                     variantdef,
+                     pointerdef,
+                     classrefdef:
+                       ;
+                     objectdef :
+                       if is_object(hp.left.resulttype.def) then
                          CGMessagePos1(hp.left.fileinfo,type_e_wrong_type_in_array_constructor,hp.left.resulttype.def.typename);
                          CGMessagePos1(hp.left.fileinfo,type_e_wrong_type_in_array_constructor,hp.left.resulttype.def.typename);
-                     end;
-                   floatdef :
-                     if not(is_currency(hp.left.resulttype.def)) then
-                       hp.left:=ctypeconvnode.create(hp.left,pbestrealtype^);
-                   procvardef :
-                     hp.left:=ctypeconvnode.create(hp.left,voidpointertype);
-                   stringdef,
-                   variantdef,
-                   pointerdef,
-                   classrefdef:
-                     ;
-                   objectdef :
-                     if is_object(hp.left.resulttype.def) then
+                     else
                        CGMessagePos1(hp.left.fileinfo,type_e_wrong_type_in_array_constructor,hp.left.resulttype.def.typename);
                        CGMessagePos1(hp.left.fileinfo,type_e_wrong_type_in_array_constructor,hp.left.resulttype.def.typename);
-                   else
-                     CGMessagePos1(hp.left.fileinfo,type_e_wrong_type_in_array_constructor,hp.left.resulttype.def.typename);
-                 end;
+                   end;
                end;
                end;
               resulttypepass(hp.left);
               resulttypepass(hp.left);
               hp:=tarrayconstructornode(hp.right);
               hp:=tarrayconstructornode(hp.right);