* fix for Mantis #37187: inside generics the constant code in pexpr does not handle all cases and thus current_procinfo needs to be checked as well

+ added test

git-svn-id: trunk@46218 -
This commit is contained in:
svenbarth 2020-08-03 21:53:14 +00:00
parent 06a5ec5b5c
commit 8770af84bd
3 changed files with 23 additions and 1 deletions

1
.gitattributes vendored
View File

@ -18381,6 +18381,7 @@ tests/webtbs/tw37107.pp svneol=native#text/pascal
tests/webtbs/tw37130.pp svneol=native#text/pascal
tests/webtbs/tw37136.pp svneol=native#text/pascal
tests/webtbs/tw37154.pp svneol=native#text/pascal
tests/webtbs/tw37187.pp svneol=native#text/pascal
tests/webtbs/tw3719.pp svneol=native#text/plain
tests/webtbs/tw3721.pp svneol=native#text/plain
tests/webtbs/tw37218.pp svneol=native#text/pascal

View File

@ -2970,9 +2970,11 @@ implementation
in_sizeof_x:
begin
{ the constant evaluation of in_sizeof_x happens in pexpr where possible }
{ the constant evaluation of in_sizeof_x happens in pexpr where possible,
though for generics it can reach here as well }
set_varstate(left,vs_read,[]);
if (left.resultdef.typ<>undefineddef) and
assigned(current_procinfo) and
paramanager.push_high_param(vs_value,left.resultdef,current_procinfo.procdef.proccalloption) then
begin
{ this should be an open array or array of const, both of

19
tests/webtbs/tw37187.pp Normal file
View File

@ -0,0 +1,19 @@
{ %NORUN }
program tw37187;
{$mode objfpc}
type
generic TTest<T: class> = class
arr: array[0..SizeOf(T)] of Byte;
end;
generic TTest2<T: class> = class
public type
TTestT = specialize TTest<T>;
end;
begin
end.