Browse Source

* Fixed IE201103063 when <dynamic array of unmanaged type> is being passed to <out open array> parameter.

git-svn-id: trunk@19684 -
sergei 13 years ago
parent
commit
3a579ced7b
3 changed files with 29 additions and 5 deletions
  1. 1 0
      .gitattributes
  2. 10 5
      compiler/ncgcal.pas
  3. 18 0
      tests/test/tarray10.pp

+ 1 - 0
.gitattributes

@@ -9766,6 +9766,7 @@ tests/test/talign2.pp svneol=native#text/plain
 tests/test/targ1a.pp svneol=native#text/plain
 tests/test/targ1b.pp svneol=native#text/plain
 tests/test/tarray1.pp svneol=native#text/plain
+tests/test/tarray10.pp svneol=native#text/plain
 tests/test/tarray2.pp svneol=native#text/plain
 tests/test/tarray3.pp svneol=native#text/plain
 tests/test/tarray4.pp svneol=native#text/plain

+ 10 - 5
compiler/ncgcal.pas

@@ -169,11 +169,16 @@ implementation
                  location_get_data_ref(current_asmdata.CurrAsmList,left.location,href,false,sizeof(pint));
                  if is_open_array(resultdef) then
                    begin
-                     if third=nil then
-                       InternalError(201103063);
-                     secondpass(third);
-                     cg.g_array_rtti_helper(current_asmdata.CurrAsmList,tarraydef(resultdef).elementdef,
-                       href,third.location,'FPC_DECREF_ARRAY');
+                     { if elementdef is not managed, omit fpc_decref_array
+                       because it won't do anything anyway }
+                     if is_managed_type(tarraydef(resultdef).elementdef) then
+                       begin
+                         if third=nil then
+                           InternalError(201103063);
+                         secondpass(third);
+                         cg.g_array_rtti_helper(current_asmdata.CurrAsmList,tarraydef(resultdef).elementdef,
+                           href,third.location,'FPC_DECREF_ARRAY');
+                       end;
                    end
                  else
                    cg.g_decrrefcount(current_asmdata.CurrAsmList,left.resultdef,href);

+ 18 - 0
tests/test/tarray10.pp

@@ -0,0 +1,18 @@
+{$mode objfpc}{$h+}
+
+procedure SetArray(out SingleArray: array of Single; const Value: Single);
+var
+  I: Integer;
+begin
+  for I := Low(SingleArray) to High(SingleArray) do
+    SingleArray[I] := Value;
+end;
+
+var
+  ValuesBuffer: array of Single;
+
+begin
+  SetLength(ValuesBuffer, 5);
+  { passing <dynamic array of unmanaged type> to <out open array> should not trigger IE 201103063 }
+  SetArray(ValuesBuffer, 5.7);
+end.