* fix for Mantis #37650: apply adjusted patch by Ryan Joseph do not range check the length of ShortStrings if their length parameter is based on a generic constant

+ added test

git-svn-id: trunk@46766 -
This commit is contained in:
svenbarth 2020-09-04 15:44:23 +00:00
parent 9a7e977167
commit b2177fb50e
3 changed files with 29 additions and 1 deletions

1
.gitattributes vendored
View File

@ -18444,6 +18444,7 @@ tests/webtbs/tw37554.pp svneol=native#text/pascal
tests/webtbs/tw3758.pp svneol=native#text/plain
tests/webtbs/tw3764.pp svneol=native#text/plain
tests/webtbs/tw3765.pp svneol=native#text/plain
tests/webtbs/tw37650.pp svneol=native#text/pascal
tests/webtbs/tw3768.pp svneol=native#text/plain
tests/webtbs/tw3774.pp svneol=native#text/plain
tests/webtbs/tw3777.pp svneol=native#text/plain

View File

@ -114,7 +114,12 @@ implementation
end
else
begin
if (tordconstnode(p).value<=0) then
{ the node is a generic param while parsing a generic def
so disable the range checking for the string }
if parse_generic and
(nf_generic_para in p.flags) then
tordconstnode(p).value:=255;
if tordconstnode(p).value<=0 then
begin
Message(parser_e_invalid_string_size);
tordconstnode(p).value:=255;

22
tests/webtbs/tw37650.pp Normal file
View File

@ -0,0 +1,22 @@
{ %NORUN }
program tw37650;
{$mode objfpc}
type
generic TMyClass<const U: Integer> = class
type TKey = String[U];
end;
generic procedure Test<const U: Integer>;
type
TKey = String[U];
begin
end;
type
TMyClass12 = specialize TMyClass<12>;
begin
specialize Test<12>;
end.