mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-20 14:29:21 +02:00
Fix for Mantis #22154:
* ptype.pas, read_named_type, array_dec: allow border checks if both range elements are orddefs; for normal arrays using e.g. "0..15" this will allow to declare the correct amount of elements in the initialization while for generic arrays (e.g. "0..SizeOf(T)") this will mean that only one element can be declared, which was already the case before this change (maybe in such cases a constant initialization should be forbidden in the future...) + added test git-svn-id: trunk@21690 -
This commit is contained in:
parent
cc65ac20c5
commit
f9211271d5
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -12659,6 +12659,7 @@ tests/webtbs/tw2198.pp svneol=native#text/plain
|
||||
tests/webtbs/tw2210.pp svneol=native#text/plain
|
||||
tests/webtbs/tw22133.pp svneol=native#text/plain
|
||||
tests/webtbs/tw2214.pp svneol=native#text/plain
|
||||
tests/webtbs/tw22154.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw2220.pp svneol=native#text/plain
|
||||
tests/webtbs/tw2226.pp svneol=native#text/plain
|
||||
tests/webtbs/tw2229.pp svneol=native#text/plain
|
||||
|
@ -1163,9 +1163,9 @@ implementation
|
||||
begin
|
||||
if pt.nodetype=rangen then
|
||||
begin
|
||||
{ check the expression only if we are not in a generic declaration }
|
||||
if not(parse_generic) then
|
||||
begin
|
||||
{ pure ordconstn expressions can be checked for
|
||||
generics as well, but don't give an error in case
|
||||
of parsing a generic if that isn't yet the case }
|
||||
if (trangenode(pt).left.nodetype=ordconstn) and
|
||||
(trangenode(pt).right.nodetype=ordconstn) then
|
||||
begin
|
||||
@ -1195,8 +1195,8 @@ implementation
|
||||
indexdef:=trangenode(pt).left.resultdef;
|
||||
end
|
||||
else
|
||||
if not parse_generic then
|
||||
Message(type_e_cant_eval_constant_expr);
|
||||
end;
|
||||
end
|
||||
else
|
||||
Message(sym_e_error_in_type_def)
|
||||
|
18
tests/webtbs/tw22154.pp
Normal file
18
tests/webtbs/tw22154.pp
Normal file
@ -0,0 +1,18 @@
|
||||
program tw22154;
|
||||
|
||||
{$MODE DELPHI}
|
||||
|
||||
type
|
||||
TWrapper<T> = class
|
||||
procedure Z;
|
||||
end;
|
||||
|
||||
procedure TWrapper<T>.Z;
|
||||
const
|
||||
A0: array [0..0] of Integer = (0); { OK }
|
||||
A1: array [0..1] of Integer = (0, 1); { Comma not exepcted }
|
||||
begin
|
||||
end;
|
||||
|
||||
begin
|
||||
end.
|
Loading…
Reference in New Issue
Block a user