mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-24 16:38:31 +02:00
* fix for Mantis #32111: allow undefined defs as a for loop's counter; the specialization will decide whether it will compile or not
+ added test git-svn-id: trunk@36722 -
This commit is contained in:
parent
b884ab31fa
commit
ca78bfffae
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -15628,6 +15628,7 @@ tests/webtbs/tw31945.pp svneol=native#text/pascal
|
|||||||
tests/webtbs/tw3197.pp svneol=native#text/plain
|
tests/webtbs/tw3197.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw3207.pp svneol=native#text/plain
|
tests/webtbs/tw3207.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw3210.pp svneol=native#text/plain
|
tests/webtbs/tw3210.pp svneol=native#text/plain
|
||||||
|
tests/webtbs/tw32111.pp svneol=native#text/pascal
|
||||||
tests/webtbs/tw3212.pp svneol=native#text/plain
|
tests/webtbs/tw3212.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw3214.pp svneol=native#text/plain
|
tests/webtbs/tw3214.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw3216.pp svneol=native#text/plain
|
tests/webtbs/tw3216.pp svneol=native#text/plain
|
||||||
|
@ -375,11 +375,14 @@ implementation
|
|||||||
loopvarsym:=nil;
|
loopvarsym:=nil;
|
||||||
|
|
||||||
{ variable must be an ordinal, int64 is not allowed for 32bit targets }
|
{ variable must be an ordinal, int64 is not allowed for 32bit targets }
|
||||||
if not(is_ordinal(hloopvar.resultdef))
|
if (
|
||||||
|
not(is_ordinal(hloopvar.resultdef))
|
||||||
{$ifndef cpu64bitaddr}
|
{$ifndef cpu64bitaddr}
|
||||||
or is_64bitint(hloopvar.resultdef)
|
or is_64bitint(hloopvar.resultdef)
|
||||||
{$endif not cpu64bitaddr}
|
{$endif not cpu64bitaddr}
|
||||||
then
|
) and
|
||||||
|
(hloopvar.resultdef.typ<>undefineddef)
|
||||||
|
then
|
||||||
MessagePos(hloopvar.fileinfo,type_e_ordinal_expr_expected);
|
MessagePos(hloopvar.fileinfo,type_e_ordinal_expr_expected);
|
||||||
|
|
||||||
hp:=hloopvar;
|
hp:=hloopvar;
|
||||||
|
59
tests/webtbs/tw32111.pp
Normal file
59
tests/webtbs/tw32111.pp
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
{ %NORUN }
|
||||||
|
|
||||||
|
program tw32111;
|
||||||
|
{$MODE OBJFPC}{$H+}{$B-}
|
||||||
|
uses
|
||||||
|
SysUtils;
|
||||||
|
|
||||||
|
type generic
|
||||||
|
TDynArray<T> = array of T;
|
||||||
|
|
||||||
|
type generic
|
||||||
|
TSorter<T, C> = class
|
||||||
|
protected
|
||||||
|
var
|
||||||
|
Tmp: C;
|
||||||
|
procedure _Sort(constref Index: specialize TDynArray<C>;
|
||||||
|
constref Values: specialize TDynArray<T>;
|
||||||
|
StartIndex, EndIndex: Int32); virtual;
|
||||||
|
public
|
||||||
|
procedure Sort(constref Index: specialize TDynArray<C>;
|
||||||
|
constref Values: specialize TDynArray<T>;
|
||||||
|
StartIndex, EndIndex: Int32); virtual;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TSorter.Sort(constref Index: specialize TDynArray<C>;
|
||||||
|
constref Values: specialize TDynArray<T>;
|
||||||
|
StartIndex, EndIndex: Int32);
|
||||||
|
var
|
||||||
|
Len: Int32;
|
||||||
|
I : C;
|
||||||
|
|
||||||
|
begin
|
||||||
|
// some code
|
||||||
|
Len:= System.Length(Values);
|
||||||
|
if (Len = 0) or ( Assigned(Index) and (Len <> System.Length(Index)) ) then Exit;
|
||||||
|
if Assigned(Index)
|
||||||
|
then begin
|
||||||
|
for I:= C(Startindex) to C(EndIndex) do Index[I]:= I;
|
||||||
|
I:= 1;
|
||||||
|
end;
|
||||||
|
Self._Sort(Index, Values, StartIndex, EndIndex);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSorter._Sort(constref Index: specialize TDynArray<C>;
|
||||||
|
constref Values: specialize TDynArray<T>;
|
||||||
|
StartIndex, EndIndex: Int32);
|
||||||
|
begin
|
||||||
|
// some code
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
s: specialize TSorter<Unicodestring, Int32>;
|
||||||
|
|
||||||
|
begin
|
||||||
|
|
||||||
|
s:= specialize TSorter<Unicodestring, Int32>.Create;
|
||||||
|
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user