compiler: also don't allow record constructors with only default arguments

git-svn-id: trunk@23438 -
This commit is contained in:
paul 2013-01-18 11:59:25 +00:00
parent fe338013a5
commit 7c663af588
5 changed files with 63 additions and 2 deletions

2
.gitattributes vendored
View File

@ -10811,7 +10811,9 @@ tests/test/terecs14.pp svneol=native#text/pascal
tests/test/terecs15.pp svneol=native#text/pascal
tests/test/terecs16.pp svneol=native#text/pascal
tests/test/terecs17.pp svneol=native#text/pascal
tests/test/terecs17a.pp svneol=native#text/pascal
tests/test/terecs18.pp svneol=native#text/pascal
tests/test/terecs18a.pp svneol=native#text/pascal
tests/test/terecs2.pp svneol=native#text/pascal
tests/test/terecs3.pp svneol=native#text/pascal
tests/test/terecs4.pp svneol=native#text/pascal

View File

@ -916,7 +916,7 @@ implementation
result:=constructor_head;
if is_objectpascal_helper(astruct) and
is_record(tobjectdef(astruct).extendeddef) and
(result.maxparacount=0) then
(result.minparacount=0) then
{ as long as parameterless constructors aren't allowed in records they
aren't allowed in helpers either }
MessagePos(result.procsym.fileinfo,parser_e_no_parameterless_constructor_in_records);

View File

@ -720,7 +720,7 @@ implementation
else
begin
pd:=constructor_head;
if pd.maxparacount = 0 then
if pd.minparacount = 0 then
MessagePos(pd.procsym.fileinfo,parser_e_no_parameterless_constructor_in_records);
end;

27
tests/test/terecs17a.pp Normal file
View File

@ -0,0 +1,27 @@
{ %FAIL }
{ %NORUN }
program terecs17a;
{$mode delphi}
type
{ TRec }
TRec = record
X: Integer;
constructor Create(I: integer = 0);
end;
{ TRec }
constructor TRec.Create(I: integer = 0);
begin
end;
var
R: TRec;
begin
R := TRec.Create;
end.

32
tests/test/terecs18a.pp Normal file
View File

@ -0,0 +1,32 @@
{ %FAIL }
{ %NORUN }
program terecs18a;
{$mode delphi}
type
{ TRec }
TRec = record
X: Integer;
end;
{ TRecHelper }
TRecHelper = record helper for TRec
constructor Create(I: Integer = 0);
end;
{ TRecHelper }
constructor TRecHelper.Create;
begin
end;
var
R: TRec;
begin
R := TRec.Create;
end.