Просмотр исходного кода

--- Merging r19684 into '.':
A tests/test/tarray10.pp
U compiler/ncgcal.pas
--- Merging r19694 into '.':
U compiler/pexpr.pas

# revisions: 19684,19694
------------------------------------------------------------------------
r19684 | sergei | 2011-11-25 15:43:17 +0100 (Fri, 25 Nov 2011) | 1 line
Changed paths:
M /trunk/compiler/ncgcal.pas
A /trunk/tests/test/tarray10.pp

* Fixed IE201103063 when <dynamic array of unmanaged type> is being passed to <out open array> parameter.
------------------------------------------------------------------------
------------------------------------------------------------------------
r19694 | sergei | 2011-11-28 09:33:18 +0100 (Mon, 28 Nov 2011) | 1 line
Changed paths:
M /trunk/compiler/pexpr.pas

* Do not access fields of potentially unassigned resultdef. p1.resultdef is not assigned at this point when dotypecheck=false. Mantis #20765.
------------------------------------------------------------------------

git-svn-id: branches/fixes_2_6@19709 -

marco 13 лет назад
Родитель
Сommit
c2470514d3
4 измененных файлов с 30 добавлено и 6 удалено
  1. 1 0
      .gitattributes
  2. 10 5
      compiler/ncgcal.pas
  3. 1 1
      compiler/pexpr.pas
  4. 18 0
      tests/test/tarray10.pp

+ 1 - 0
.gitattributes

@@ -9735,6 +9735,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);

+ 1 - 1
compiler/pexpr.pas

@@ -2966,7 +2966,7 @@ implementation
            _ASSIGNMENT :
              begin
                 consume(_ASSIGNMENT);
-                if (p1.resultdef.typ=procvardef) then
+                if assigned(p1.resultdef) and (p1.resultdef.typ=procvardef) then
                   getprocvardef:=tprocvardef(p1.resultdef);
                 p2:=sub_expr(opcompare,true,false);
                 if assigned(getprocvardef) then

+ 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.