mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 13:49:29 +02:00
* constrained type parameters are not undefined defs, resolves #37107
git-svn-id: trunk@45457 -
This commit is contained in:
parent
4caa471a24
commit
51da470757
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
||||
|
@ -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
19
tests/webtbs/tw37107.pp
Normal 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.
|
Loading…
Reference in New Issue
Block a user