mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-22 13:49:17 +02:00
* handle inc/dec/pred/succ correctly with type parameters, resolves #23299
git-svn-id: trunk@23248 -
This commit is contained in:
parent
f2ee6bcb77
commit
d140c5b4ee
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -13083,6 +13083,7 @@ tests/webtbs/tw23212.pp svneol=native#text/plain
|
|||||||
tests/webtbs/tw2323.pp svneol=native#text/plain
|
tests/webtbs/tw2323.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw23270.pp svneol=native#text/pascal
|
tests/webtbs/tw23270.pp svneol=native#text/pascal
|
||||||
tests/webtbs/tw2328.pp svneol=native#text/plain
|
tests/webtbs/tw2328.pp svneol=native#text/plain
|
||||||
|
tests/webtbs/tw23299.pp svneol=native#text/pascal
|
||||||
tests/webtbs/tw2332.pp svneol=native#text/plain
|
tests/webtbs/tw2332.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw23342.pp svneol=native#text/pascal
|
tests/webtbs/tw23342.pp svneol=native#text/pascal
|
||||||
tests/webtbs/tw23436.pp svneol=native#text/plain
|
tests/webtbs/tw23436.pp svneol=native#text/plain
|
||||||
|
@ -2698,15 +2698,15 @@ implementation
|
|||||||
begin
|
begin
|
||||||
set_varstate(left,vs_read,[vsf_must_be_valid]);
|
set_varstate(left,vs_read,[vsf_must_be_valid]);
|
||||||
resultdef:=left.resultdef;
|
resultdef:=left.resultdef;
|
||||||
if not is_ordinal(resultdef) then
|
if is_ordinal(resultdef) or is_typeparam(resultdef) then
|
||||||
CGMessage(type_e_ordinal_expr_expected)
|
|
||||||
else
|
|
||||||
begin
|
begin
|
||||||
if (resultdef.typ=enumdef) and
|
if (resultdef.typ=enumdef) and
|
||||||
(tenumdef(resultdef).has_jumps) and
|
(tenumdef(resultdef).has_jumps) and
|
||||||
not(m_delphi in current_settings.modeswitches) then
|
not(m_delphi in current_settings.modeswitches) then
|
||||||
CGMessage(type_e_succ_and_pred_enums_with_assign_not_possible);
|
CGMessage(type_e_succ_and_pred_enums_with_assign_not_possible);
|
||||||
end;
|
end
|
||||||
|
else
|
||||||
|
CGMessage(type_e_ordinal_expr_expected)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
in_copy_x:
|
in_copy_x:
|
||||||
@ -2771,6 +2771,12 @@ implementation
|
|||||||
CGMessagePos(tcallparanode(left).right.fileinfo,type_e_ordinal_expr_expected);
|
CGMessagePos(tcallparanode(left).right.fileinfo,type_e_ordinal_expr_expected);
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
|
{ generic type parameter? }
|
||||||
|
else if is_typeparam(left.resultdef) then
|
||||||
|
begin
|
||||||
|
result:=cnothingnode.create;
|
||||||
|
exit;
|
||||||
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
hp:=self;
|
hp:=self;
|
||||||
|
26
tests/webtbs/tw23299.pp
Normal file
26
tests/webtbs/tw23299.pp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{$MODE DELPHI}
|
||||||
|
|
||||||
|
type
|
||||||
|
TSmallWrapper<TValue> = record
|
||||||
|
Value: TValue;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TWrapper<T> = class
|
||||||
|
strict private
|
||||||
|
class var FSmallWrapper: TSmallWrapper<Integer>;
|
||||||
|
public
|
||||||
|
class procedure Z; static;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TWrapper<T>.Z;
|
||||||
|
begin
|
||||||
|
FSmallWrapper.Value := 0;
|
||||||
|
Inc(FSmallWrapper.Value);
|
||||||
|
Dec(FSmallWrapper.Value);
|
||||||
|
FSmallWrapper.Value := Succ(FSmallWrapper.Value);
|
||||||
|
FSmallWrapper.Value := Pred(FSmallWrapper.Value);
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
TWrapper<Byte>.Z;
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user