fpc/tests/tbf/tb0247.pp
svenbarth a7a9440692 Add a new warning message that is generated if an instance of an abstract class is created. This message is disabled by default, but can be switched on by using {$warn 4122 on} or {$warn 4122 error}.
Please note that this warning won't be triggered if an instance of that class is created using a class variable of that class type as the compiler can not know the type contained in the variable at compile time (see also the added test).

+ msg/errore.msg: added disabled message which informs about the instantiation of an abstract class
* pexpr.pas, do_member_read: generate the message if we have a constructor call for an abstract class using a loadvmtaddrnode (thus the type name is used and not a class variable)

* msg{idx,txt}.inc: updated

+ added test

git-svn-id: trunk@28127 -
2014-07-01 20:41:05 +00:00

31 lines
366 B
ObjectPascal

{ %FAIL }
program tb0247;
{$WARN 4122 ERROR}
{$mode objfpc}
type
TTest = class abstract
end;
TTestClass = class of TTest;
TTestSub = class
end;
var
o: TObject;
c: TTestClass;
begin
{ this should not create an error }
o := c.Create;
{ this neither }
o := TTestSub.Create;
{ but this should create an error }
o := TTest.Create;
end.