* constrained type parameters are not undefined defs, resolves #37107

git-svn-id: trunk@45457 -
This commit is contained in:
florian 2020-05-21 18:19:08 +00:00
parent 4caa471a24
commit 51da470757
4 changed files with 22 additions and 2 deletions

1
.gitattributes vendored
View File

@ -18291,6 +18291,7 @@ tests/webtbs/tw37062.pp svneol=native#text/pascal
tests/webtbs/tw3708.pp svneol=native#text/plain
tests/webtbs/tw37095.pp svneol=native#text/plain
tests/webtbs/tw37095d/uw37095.pp svneol=native#text/plain
tests/webtbs/tw37107.pp svneol=native#text/pascal
tests/webtbs/tw3719.pp svneol=native#text/plain
tests/webtbs/tw3721.pp svneol=native#text/plain
tests/webtbs/tw3742.pp svneol=native#text/plain

View File

@ -1821,7 +1821,7 @@ implementation
function is_typeparam(def : tdef) : boolean;{$ifdef USEINLINE}inline;{$endif}
begin
result:=(def.typ=undefineddef);
result:=(def.typ=undefineddef) or (df_genconstraint in def.defoptions);
end;

View File

@ -443,7 +443,7 @@ implementation
is_open_string(p1.resultdef)
)) or
{ keep the function call if it is a type parameter to avoid arithmetic errors due to constant folding }
(p1.resultdef.typ=undefineddef) then
is_typeparam(p1.resultdef) then
begin
statement_syssym:=geninlinenode(in_sizeof_x,false,p1);
{ no packed bit support for these things }

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

@ -0,0 +1,19 @@
program genTest;
{$IFDEF FPC}{$mode Delphi}{$ENDIF}
type
TTest<T: Record> = class(TObject)
procedure testit();
end;
procedure TTest<T>.testit();
begin
WriteLn('=== ', 1 div SizeOf(T));
if SizeOf(T) > 0 then
WriteLn('I''m reachable!')
end;
begin
TTest<Char>.Create().TestIt();
end.