Преглед изворни кода

* 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

Sven/Sarah Barth пре 2 година
родитељ
комит
d97d34ee9c
2 измењених фајлова са 22 додато и 1 уклоњено
  1. 1 1
      compiler/ncal.pas
  2. 21 0
      tests/webtbs/tw40332.pp

+ 1 - 1
compiler/ncal.pas

@@ -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 - 0
tests/webtbs/tw40332.pp

@@ -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.