From 233622157c86f32cf024499ab12c036a2cf73e7d Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Fri, 7 Oct 2016 16:41:32 +0000 Subject: [PATCH] * don't attempt to load the VMT of a niln when taking the address of a class method (mantis #30706) git-svn-id: trunk@34641 - --- .gitattributes | 1 + compiler/nld.pas | 3 ++- tests/webtbs/tw30706.pp | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/webtbs/tw30706.pp diff --git a/.gitattributes b/.gitattributes index 3eb5e8a6db..cb7214794a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15242,6 +15242,7 @@ tests/webtbs/tw30572.pp svneol=native#text/plain tests/webtbs/tw3063.pp svneol=native#text/plain tests/webtbs/tw3064.pp svneol=native#text/plain tests/webtbs/tw30666.pp svneol=native#text/plain +tests/webtbs/tw30706.pp svneol=native#text/plain tests/webtbs/tw3073.pp svneol=native#text/plain tests/webtbs/tw3082.pp svneol=native#text/plain tests/webtbs/tw3083.pp svneol=native#text/plain diff --git a/compiler/nld.pas b/compiler/nld.pas index a4966bf312..f3969a18cb 100644 --- a/compiler/nld.pas +++ b/compiler/nld.pas @@ -368,7 +368,8 @@ implementation begin typecheckpass(left); if (po_classmethod in fprocdef.procoptions) and - is_class(left.resultdef) then + is_class(left.resultdef) and + (left.nodetype<>niln) then begin left:=cloadvmtaddrnode.create(left); typecheckpass(left); diff --git a/tests/webtbs/tw30706.pp b/tests/webtbs/tw30706.pp new file mode 100644 index 0000000000..22888caa3e --- /dev/null +++ b/tests/webtbs/tw30706.pp @@ -0,0 +1,24 @@ +{$mode objfpc}{$H+} + +uses SysUtils; + +type + TMyMethod = procedure (A: Integer) of object; + + TMyClass = class + class procedure Foo(A: Integer); + end; + +class procedure TMyClass.Foo(A: Integer); +begin + Writeln('Got int ', A); +end; + +procedure CallMethod(M: TMyMethod); +begin + M(123); +end; + +begin + CallMethod({$ifdef FPC_OBJFPC} @ {$endif} TMyClass(nil).Foo); +end.