mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-19 00:39:34 +02:00
compiler: allow constructors in helpers for records
git-svn-id: trunk@23407 -
This commit is contained in:
parent
cce67cf5ae
commit
e9615716c1
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -11436,6 +11436,7 @@ tests/test/trhlp41.pp svneol=native#text/pascal
|
||||
tests/test/trhlp42.pp svneol=native#text/pascal
|
||||
tests/test/trhlp43.pp svneol=native#text/pascal
|
||||
tests/test/trhlp44.pp svneol=native#text/pascal
|
||||
tests/test/trhlp45.pp svneol=native#text/pascal
|
||||
tests/test/trhlp5.pp svneol=native#text/pascal
|
||||
tests/test/trhlp6.pp svneol=native#text/pascal
|
||||
tests/test/trhlp7.pp svneol=native#text/pascal
|
||||
|
@ -901,11 +901,7 @@ implementation
|
||||
if is_objectpascal_helper(astruct) then
|
||||
if is_classdef then
|
||||
{ class constructors are not allowed in class helpers }
|
||||
Message(parser_e_no_class_constructor_in_helpers)
|
||||
else if is_record(tobjectdef(astruct).extendeddef) then
|
||||
{ as long as constructors aren't allowed in records they
|
||||
aren't allowed in helpers either }
|
||||
Message(parser_e_no_constructor_in_records);
|
||||
Message(parser_e_no_class_constructor_in_helpers);
|
||||
|
||||
{ only 1 class constructor is allowed }
|
||||
if is_classdef and (oo_has_class_constructor in astruct.objectoptions) then
|
||||
|
@ -493,7 +493,11 @@ implementation
|
||||
end;
|
||||
end
|
||||
else
|
||||
if not is_record(current_structdef) then
|
||||
if not is_record(current_structdef) and
|
||||
not (
|
||||
is_objectpascal_helper(current_structdef) and
|
||||
is_record(tobjectdef(current_structdef).extendeddef)
|
||||
) then
|
||||
internalerror(200305103);
|
||||
{ if self=nil then exit
|
||||
calling fail instead of exit is useless because
|
||||
|
28
tests/test/trhlp45.pp
Normal file
28
tests/test/trhlp45.pp
Normal file
@ -0,0 +1,28 @@
|
||||
program trhlp45;
|
||||
|
||||
{$mode delphi}
|
||||
|
||||
type
|
||||
TRec = record
|
||||
X: Integer;
|
||||
end;
|
||||
|
||||
THelpRec = record helper for TRec
|
||||
constructor Create(AX: Integer);
|
||||
end;
|
||||
|
||||
|
||||
{ THelpRec }
|
||||
|
||||
constructor THelpRec.Create(AX: Integer);
|
||||
begin
|
||||
X := AX;
|
||||
end;
|
||||
|
||||
var
|
||||
R: TRec;
|
||||
begin
|
||||
R := TRec.Create(1);
|
||||
if R.X <> 1 then
|
||||
halt(1);
|
||||
end.
|
Loading…
Reference in New Issue
Block a user