fpc/tests/test/cg/tctr1a.pp
sergei f8e921e478 * Fixed code generation for constructors compiled in {$implicitexeptions off} state, or having no implicit finally frame. Exit label and finalization code have to be placed before call to AfterConstruction, so exit statements do not jump over AfterConstruction, and overall control flow is the same as in default {$implicitexceptions on} state.
* A second attempt to remove unconditional pi_needs_implicit_finally from constructors, should hopefully be correct this time due to the changes described above.
+ Test (a copy of tctr1.pp with additional {$implicitexceptions off} directive)

git-svn-id: trunk@19955 -
2012-01-02 20:07:24 +00:00

31 lines
484 B
ObjectPascal

{$mode objfpc}{$h+}
// Differs from tctr1.pp in the following directive:
{$implicitexceptions off}
type
tobj=class(TObject)
ffield:boolean;
constructor Create;
procedure AfterConstruction;override;
end;
{ Exit statement in constructor must not jump over AfterConstruction! }
constructor tobj.Create;
begin
exit;
end;
procedure tobj.AfterConstruction;
begin
ffield:=true;
end;
var
o: tobj;
begin
o:=tobj.create;
if not o.ffield then
Halt(1);
end.