* don't allow constants of the record type that is currently being parsed; this would fail as soon as another field is added after the constant declaration

+ added tests
Note: unlike what bug report 27880 suggests Delphi also does *NOT* allow this (at least a current Delphi Tokyo) and fails with a "type is not completely defined" error, so this test belongs into the "failure" category

git-svn-id: trunk@40285 -
This commit is contained in:
svenbarth 2018-11-11 22:08:29 +00:00
parent 446f89719c
commit 251dfb6776
8 changed files with 107 additions and 2 deletions

7
.gitattributes vendored
View File

@ -11064,6 +11064,11 @@ tests/tbf/tb0257b.pp svneol=native#text/pascal
tests/tbf/tb0258.pp svneol=native#text/pascal
tests/tbf/tb0259.pp svneol=native#text/plain
tests/tbf/tb0260.pp svneol=native#text/plain
tests/tbf/tb0261.pp svneol=native#text/pascal
tests/tbf/tb0262.pp svneol=native#text/pascal
tests/tbf/tb0263.pp svneol=native#text/pascal
tests/tbf/tb0264.pp svneol=native#text/pascal
tests/tbf/tb0265.pp svneol=native#text/pascal
tests/tbf/ub0115.pp svneol=native#text/plain
tests/tbf/ub0149.pp svneol=native#text/plain
tests/tbf/ub0158a.pp svneol=native#text/plain
@ -14657,6 +14662,7 @@ tests/webtbf/tw2739.pp svneol=native#text/plain
tests/webtbf/tw2751.pp svneol=native#text/plain
tests/webtbf/tw2752.pp svneol=native#text/plain
tests/webtbf/tw2787.pp svneol=native#text/plain
tests/webtbf/tw27880.pp svneol=native#text/pascal
tests/webtbf/tw2795.pp svneol=native#text/plain
tests/webtbf/tw28338.pp svneol=native#text/plain
tests/webtbf/tw28355.pp svneol=native#text/plain
@ -16031,7 +16037,6 @@ tests/webtbs/tw2780.pp svneol=native#text/plain
tests/webtbs/tw27811.pp svneol=native#text/plain
tests/webtbs/tw27832.pp svneol=native#text/plain
tests/webtbs/tw2788.pp svneol=native#text/plain
tests/webtbs/tw27880.pp svneol=native#text/plain
tests/webtbs/tw2789.pp svneol=native#text/plain
tests/webtbs/tw2794.pp svneol=native#text/plain
tests/webtbs/tw27998.pp svneol=native#text/plain

View File

@ -274,6 +274,9 @@ implementation
to it from the structure or linking will fail }
if symtablestack.top.symtabletype in [recordsymtable,ObjectSymtable] then
begin
{ note: we keep hdef so that we might at least read the
constant data correctly for error recovery }
check_allowed_for_var_or_const(hdef,false);
sym:=cfieldvarsym.create(orgname,varspez,hdef,[],true);
symtablestack.top.insert(sym);
sym:=make_field_static(symtablestack.top,tfieldvarsym(sym));

18
tests/tbf/tb0261.pp Normal file
View File

@ -0,0 +1,18 @@
{ %FAIL }
program tb0261;
{$mode objfpc}
{$modeswitch advancedrecords}
type
TTest = record
public
a, b: LongInt;
public const
Test: TTest = (a: 42; b: 21);
end;
begin
end.

18
tests/tbf/tb0262.pp Normal file
View File

@ -0,0 +1,18 @@
{ %FAIL }
program tb0262;
{$mode objfpc}
{$modeswitch advancedrecords}
type
TTest = record
public
a, b: LongInt;
public const
Test: array[0..1] of TTest = ((a: 42; b: 21), (a: 21; b: 42));
end;
begin
end.

20
tests/tbf/tb0263.pp Normal file
View File

@ -0,0 +1,20 @@
{ %FAIL }
program tb0263;
{$mode objfpc}
{$modeswitch advancedrecords}
type
TTest = record
public
a, b: LongInt;
public const
Test: array[0..1] of record
t: TTest;
end = ((t: (a: 42; b: 21)), (t: (a: 21; b: 42)));
end;
begin
end.

21
tests/tbf/tb0264.pp Normal file
View File

@ -0,0 +1,21 @@
{ %FAIL }
program tb0264;
{$mode objfpc}
{$modeswitch advancedrecords}
type
TTest = record
public
a, b: LongInt;
public type
TSubType = record
public const
Test: TTest = (a: 42; b: 21);
end;
end;
begin
end.

20
tests/tbf/tb0265.pp Normal file
View File

@ -0,0 +1,20 @@
{ %FAIL }
program tb0265;
{$mode objfpc}
{$modeswitch advancedrecords}
type
TTest = record
public
a, b: LongInt;
public const
Test: array of record
t: TTest;
end = ((t: (a: 42; b: 21)), (t: (a: 21; b: 42)));
end;
begin
end.

View File

@ -1,4 +1,4 @@
{ %norun }
{ %FAIL }
program project1;