Prechádzať zdrojové kódy

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

git-svn-id: trunk@23438 -
paul 12 rokov pred
rodič
commit
7c663af588

+ 2 - 0
.gitattributes

@@ -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

+ 1 - 1
compiler/pdecobj.pas

@@ -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);

+ 1 - 1
compiler/ptype.pas

@@ -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 - 0
tests/test/terecs17a.pp

@@ -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 - 0
tests/test/terecs18a.pp

@@ -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.