* Allow for "record constraint" in Delphi mode more types like: ordinal, float, classical objects, enumerations (instead of just record). Delphi compatibility. Fix for mantis #24073.

git-svn-id: trunk@35739 -
This commit is contained in:
maciej-izak 2017-04-05 13:12:30 +00:00
parent 07c98e816f
commit e4565378db
3 changed files with 47 additions and 1 deletions

1
.gitattributes vendored
View File

@ -14966,6 +14966,7 @@ tests/webtbs/tw23980.pp svneol=native#text/pascal
tests/webtbs/tw24007.pp svneol=native#text/plain
tests/webtbs/tw24071.pp svneol=native#text/pascal
tests/webtbs/tw24072.pp svneol=native#text/pascal
tests/webtbs/tw24073.pp svneol=native#text/pascal
tests/webtbs/tw2409.pp svneol=native#text/plain
tests/webtbs/tw24129.pp svneol=native#text/pascal
tests/webtbs/tw24131.pp svneol=native#text/plain

View File

@ -144,7 +144,22 @@ uses
begin
case formaldef.typ of
recorddef:
MessagePos(filepos,type_e_record_type_expected);
{ delphi has own fantasy about record constraint
(almost non-nullable/non-nilable value type) }
if m_delphi in current_settings.modeswitches then
case paradef.typ of
floatdef,enumdef,orddef:
continue;
objectdef:
if tobjectdef(paradef).objecttype=odt_object then
continue
else
MessagePos(filepos,type_e_record_type_expected);
else
MessagePos(filepos,type_e_record_type_expected);
end
else
MessagePos(filepos,type_e_record_type_expected);
objectdef:
case tobjectdef(formaldef).objecttype of
odt_class,

30
tests/webtbs/tw24073.pp Normal file
View File

@ -0,0 +1,30 @@
{ %NORUN }
{$MODE DELPHI}
type
TA<T: record> = record
end;
TUnamanagedRec = record
x: integer;
end;
TManagedRec = record
s: string;
end;
TEnum = (e1, e2, e3);
TObj = object
end;
var
a: TA<TUnamanagedRec>;
b: TA<TManagedRec>;
d: TA<Single>;
e: TA<Integer>;
f: TA<TEnum>;
g: TA<TObj>;
begin
end.