From c3c345d569eedb8fc51d427f5b730c969c5a6408 Mon Sep 17 00:00:00 2001 From: svenbarth Date: Wed, 1 Jun 2016 20:03:59 +0000 Subject: [PATCH] Fix for Mantis #30202. pexpr.pas, sub_expr.generate_inline_specialization: * do_member_read() needs to happen independently of whether we're calling a method of the same object (was incorrectly copypasted code... :/ ) + added test git-svn-id: trunk@33875 - --- .gitattributes | 1 + compiler/pexpr.pas | 22 ++++++++--------- tests/webtbs/tw30202.pp | 53 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 12 deletions(-) create mode 100644 tests/webtbs/tw30202.pp diff --git a/.gitattributes b/.gitattributes index 34a2690d56..80599dce79 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15109,6 +15109,7 @@ tests/webtbs/tw30119a.pp svneol=native#text/pascal tests/webtbs/tw30119b.pp svneol=native#text/pascal tests/webtbs/tw3012.pp svneol=native#text/plain tests/webtbs/tw30166.pp svneol=native#text/plain +tests/webtbs/tw30202.pp svneol=native#text/pascal tests/webtbs/tw3023.pp svneol=native#text/plain tests/webtbs/tw3028.pp svneol=native#text/plain tests/webtbs/tw3038.pp svneol=native#text/plain diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas index 529023521c..957f5a0864 100644 --- a/compiler/pexpr.pas +++ b/compiler/pexpr.pas @@ -3992,19 +3992,17 @@ implementation { class we need to call it as a class member } if (gensym.owner.symtabletype in [ObjectSymtable,recordsymtable]) and assigned(current_structdef) and (current_structdef<>parseddef) and is_owned_by(current_structdef,parseddef) then + result:=cloadvmtaddrnode.create(ctypenode.create(parseddef)); + { not srsymtable.symtabletype since that can be } + { withsymtable as well } + if (gensym.owner.symtabletype in [ObjectSymtable,recordsymtable]) then begin - result:=cloadvmtaddrnode.create(ctypenode.create(parseddef)); - { not srsymtable.symtabletype since that can be } - { withsymtable as well } - if (gensym.owner.symtabletype in [ObjectSymtable,recordsymtable]) then - begin - do_member_read(tabstractrecorddef(parseddef),getaddr,gensym,result,again,[],spezcontext); - spezcontext:=nil; - end - else - { no procsyms in records (yet) } - internalerror(2015092704); - end; + do_member_read(tabstractrecorddef(parseddef),getaddr,gensym,result,again,[],spezcontext); + spezcontext:=nil; + end + else + { no procsyms in records (yet) } + internalerror(2015092704); end else begin diff --git a/tests/webtbs/tw30202.pp b/tests/webtbs/tw30202.pp new file mode 100644 index 0000000000..0ff7f374ff --- /dev/null +++ b/tests/webtbs/tw30202.pp @@ -0,0 +1,53 @@ +{ %NORUN } + +program tw30202; + +{$MODE DELPHI} +{$POINTERMATH ON} + +type + TArray = record + class procedure QuickSort(var A: Array of T; const Index, Count: Integer); static; inline; + end; + +class procedure TArray.QuickSort(var A: Array of T; const Index, Count: Integer); +var + I, J: Integer; + Temp, Pivot: T; +begin + if Index < Count then + begin + Pivot := A[Random(Count - Index) + Index + 1]; + I := Index - 1; + J := Count + 1; + repeat + repeat Inc(I) until A[I] >= Pivot; + repeat Dec(J) until A[J] <= Pivot; + Temp := A[I]; + A[I] := A[J]; + A[J] := Temp; + until I >= J; + A[J] := A[I]; + A[I] := Temp; + QuickSort(A, Index, I - 1); // project1.lpr(30,17) Error: Compilation raised exception internally + QuickSort(A, I, Count); + end; +end; + +var + arri: array of LongInt; + arrs: array of String; +begin + SetLength(arri, 4); + arri[0] := 4; + arri[1] := 2; + arri[2] := 6; + arri[3] := 1; + SetLength(arrs, 4); + arrs[0] := 'World'; + arrs[1] := 'Alpha'; + arrs[2] := 'Hello'; + arrs[3] := 'Foo'; + TArray.QuickSort(arri, Low(arri), High(arri)); + TArray.QuickSort(arrs, Low(arrs), High(arrs)); +end.