tw19591.pp 755 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. { %fail }
  2. { %CPU=i386 }
  3. { %target=windows,linux }
  4. { Target must have distinct stdcall and cdecl calling conventions, otherwise this test will (wrongly) succeed }
  5. {$mode objfpc}{$H+}
  6. {$MACRO ON}
  7. uses
  8. Classes;
  9. type
  10. // Declare wrong calling convention
  11. {$ifdef WINDOWS}
  12. {$DEFINE extdecl := cdecl}
  13. {$else}
  14. {$DEFINE extdecl := stdcall}
  15. {$endif}
  16. { TObj }
  17. TObj = class(TInterfacedObject, IUnknown)
  18. function IUnknown._AddRef = AddRef; // This must produce a error because of calling convention mismatch.
  19. function AddRef : longint;extdecl;
  20. end;
  21. { TObj }
  22. function TObj.AddRef: longint;extdecl;
  23. begin
  24. WriteLn('TObj.AddRef call');
  25. inherited;
  26. end;
  27. var O:TObj;
  28. begin
  29. O:=TObj.Create;
  30. (O as IUnknown)._AddRef;
  31. O.Free;
  32. end.