* fix #40332: apply patch by Rika to avoid a crash when an overload can't be picked outside of a function (e.g. when using intrinsics inside constants)

+ added test
This commit is contained in:
Sven/Sarah Barth 2023-06-30 15:35:28 +02:00
parent 9cc08940dd
commit d97d34ee9c
2 changed files with 22 additions and 1 deletions

View File

@ -3823,7 +3823,7 @@ implementation
with generic types as arguments we don't complain in
the generic, but only during the specialization }
ignoregenericparacall:=false;
if df_generic in current_procinfo.procdef.defoptions then
if assigned(current_procinfo) and (df_generic in current_procinfo.procdef.defoptions) then
begin
pt:=tcallparanode(left);
while assigned(pt) do

21
tests/webtbs/tw40332.pp Normal file
View File

@ -0,0 +1,21 @@
{$mode objfpc}
unit tw40332;
interface
function Bsr(const value: byte): byte; internproc: fpc_in_bsr_x;
function Bsr(const value: word): cardinal; internproc: fpc_in_bsr_x;
function Bsr(const value: dword): cardinal; internproc: fpc_in_bsr_x;
{$ifdef cpu64}
function Bsr(const value: qword): cardinal; internproc: fpc_in_bsr_x;
{$endif}
type
SomeEnum = (A, B, C, D);
const
SomeEnumBits = 1 + Bsr(ord(High(SomeEnum)) or 1);
implementation
end.