mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-11 19:08:07 +02:00
45 lines
755 B
ObjectPascal
45 lines
755 B
ObjectPascal
{ %fail }
|
|
{ %CPU=i386 }
|
|
{ %target=windows,linux }
|
|
{ Target must have distinct stdcall and cdecl calling conventions, otherwise this test will (wrongly) succeed }
|
|
|
|
{$mode objfpc}{$H+}
|
|
{$MACRO ON}
|
|
|
|
uses
|
|
Classes;
|
|
|
|
type
|
|
// Declare wrong calling convention
|
|
{$ifdef WINDOWS}
|
|
{$DEFINE extdecl := cdecl}
|
|
{$else}
|
|
{$DEFINE extdecl := stdcall}
|
|
{$endif}
|
|
|
|
{ TObj }
|
|
|
|
TObj = class(TInterfacedObject, IUnknown)
|
|
|
|
function IUnknown._AddRef = AddRef; // This must produce a error because of calling convention mismatch.
|
|
|
|
function AddRef : longint;extdecl;
|
|
end;
|
|
|
|
{ TObj }
|
|
|
|
function TObj.AddRef: longint;extdecl;
|
|
begin
|
|
WriteLn('TObj.AddRef call');
|
|
inherited;
|
|
end;
|
|
|
|
var O:TObj;
|
|
|
|
begin
|
|
O:=TObj.Create;
|
|
(O as IUnknown)._AddRef;
|
|
O.Free;
|
|
end.
|
|
|