Browse Source

Merged revisions 1472 via svnmerge from
http://[email protected]/svn/fpc/trunk

r1472 (peter)
* all types with inittable need a persistant temp

git-svn-id: branches/fixes_2_0@1508 -

peter 20 years ago
parent
commit
f840880c26
3 changed files with 33 additions and 17 deletions
  1. 1 0
      .gitattributes
  2. 1 17
      compiler/ncgld.pas
  3. 31 0
      tests/webtbs/tw4104.pp

+ 1 - 0
.gitattributes

@@ -6025,6 +6025,7 @@ tests/webtbs/tw4089.pp svneol=native#text/plain
 tests/webtbs/tw4093.pp svneol=native#text/plain
 tests/webtbs/tw4093.pp svneol=native#text/plain
 tests/webtbs/tw4098.pp svneol=native#text/plain
 tests/webtbs/tw4098.pp svneol=native#text/plain
 tests/webtbs/tw4100.pp svneol=native#text/plain
 tests/webtbs/tw4100.pp svneol=native#text/plain
+tests/webtbs/tw4104.pp svneol=native#text/plain
 tests/webtbs/tw4115.pp svneol=native#text/plain
 tests/webtbs/tw4115.pp svneol=native#text/plain
 tests/webtbs/tw4119.pp svneol=native#text/plain
 tests/webtbs/tw4119.pp svneol=native#text/plain
 tests/webtbs/tw4140.pp svneol=native#text/plain
 tests/webtbs/tw4140.pp svneol=native#text/plain

+ 1 - 17
compiler/ncgld.pas

@@ -828,24 +828,10 @@ implementation
                         end
                         end
                        else
                        else
                         if is_ansistring(lt) then
                         if is_ansistring(lt) then
-                        {$ifdef ansistring_bits}
-                         begin
-                           case Tstringdef(lt).string_typ of
-                             st_ansistring16:
-                               vtype:=vtAnsiString16;
-                             st_ansistring32:
-                               vtype:=vtAnsiString32;
-                             st_ansistring64:
-                               vtype:=vtAnsiString64;
-                           end;
-                           freetemp:=false;
-                         end
-                        {$else}
                          begin
                          begin
                            vtype:=vtAnsiString;
                            vtype:=vtAnsiString;
                            freetemp:=false;
                            freetemp:=false;
                          end
                          end
-                        {$endif}
                        else
                        else
                         if is_widestring(lt) then
                         if is_widestring(lt) then
                          begin
                          begin
@@ -876,9 +862,7 @@ implementation
               else
               else
               { normal array constructor of the same type }
               { normal array constructor of the same type }
                begin
                begin
-                 if (is_ansistring(left.resulttype.def) or
-                     is_widestring(left.resulttype.def) or
-                     (left.resulttype.def.deftype=variantdef)) then
+                 if resulttype.def.needs_inittable then
                    freetemp:=false;
                    freetemp:=false;
                  case hp.left.location.loc of
                  case hp.left.location.loc of
                    LOC_FPUREGISTER,
                    LOC_FPUREGISTER,

+ 31 - 0
tests/webtbs/tw4104.pp

@@ -0,0 +1,31 @@
+{ Source provided for Free Pascal Bug Report 4104 }
+{ Submitted by "Daniël Mantione" on  2005-06-22 }
+{ e-mail: [email protected] }
+program bug;
+
+type junk=record
+       data:ansistring;
+     end;
+
+operator :=(x:longint) result:junk;
+
+begin
+  str(x,result.data);
+end;
+
+procedure write_junk(const data:array of junk);
+
+var i:cardinal;
+
+begin
+  for i:=low(data) to high(data) do
+   begin
+     write(data[i].data);
+     write('<-->');
+     writeln(Pchar(data[i].data));
+   end;
+end;
+
+begin
+  write_junk([1,2]);
+end.