mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 04:29:17 +02:00
compiler: also don't allow record constructors with only default arguments
git-svn-id: trunk@23438 -
This commit is contained in:
parent
fe338013a5
commit
7c663af588
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -10811,7 +10811,9 @@ tests/test/terecs14.pp svneol=native#text/pascal
|
|||||||
tests/test/terecs15.pp svneol=native#text/pascal
|
tests/test/terecs15.pp svneol=native#text/pascal
|
||||||
tests/test/terecs16.pp svneol=native#text/pascal
|
tests/test/terecs16.pp svneol=native#text/pascal
|
||||||
tests/test/terecs17.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/terecs18.pp svneol=native#text/pascal
|
||||||
|
tests/test/terecs18a.pp svneol=native#text/pascal
|
||||||
tests/test/terecs2.pp svneol=native#text/pascal
|
tests/test/terecs2.pp svneol=native#text/pascal
|
||||||
tests/test/terecs3.pp svneol=native#text/pascal
|
tests/test/terecs3.pp svneol=native#text/pascal
|
||||||
tests/test/terecs4.pp svneol=native#text/pascal
|
tests/test/terecs4.pp svneol=native#text/pascal
|
||||||
|
@ -916,7 +916,7 @@ implementation
|
|||||||
result:=constructor_head;
|
result:=constructor_head;
|
||||||
if is_objectpascal_helper(astruct) and
|
if is_objectpascal_helper(astruct) and
|
||||||
is_record(tobjectdef(astruct).extendeddef) 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
|
{ as long as parameterless constructors aren't allowed in records they
|
||||||
aren't allowed in helpers either }
|
aren't allowed in helpers either }
|
||||||
MessagePos(result.procsym.fileinfo,parser_e_no_parameterless_constructor_in_records);
|
MessagePos(result.procsym.fileinfo,parser_e_no_parameterless_constructor_in_records);
|
||||||
|
@ -720,7 +720,7 @@ implementation
|
|||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
pd:=constructor_head;
|
pd:=constructor_head;
|
||||||
if pd.maxparacount = 0 then
|
if pd.minparacount = 0 then
|
||||||
MessagePos(pd.procsym.fileinfo,parser_e_no_parameterless_constructor_in_records);
|
MessagePos(pd.procsym.fileinfo,parser_e_no_parameterless_constructor_in_records);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
27
tests/test/terecs17a.pp
Normal file
27
tests/test/terecs17a.pp
Normal 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
32
tests/test/terecs18a.pp
Normal 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.
|
Loading…
Reference in New Issue
Block a user