* allow use of multiple, comma separated attributes as Delphi allows that as well

+ added test

git-svn-id: trunk@42409 -
This commit is contained in:
svenbarth 2019-07-12 22:08:14 +00:00
parent 6d0c470a40
commit 87458a065c
3 changed files with 112 additions and 68 deletions

1
.gitattributes vendored
View File

@ -13215,6 +13215,7 @@ tests/test/tcustomattr15.pp svneol=native#text/pascal
tests/test/tcustomattr16.pp svneol=native#text/pascal
tests/test/tcustomattr17.pp svneol=native#text/pascal
tests/test/tcustomattr18.pp svneol=native#text/pascal
tests/test/tcustomattr19.pp svneol=native#text/pascal
tests/test/tcustomattr2.pp svneol=native#text/pascal
tests/test/tcustomattr3.pp svneol=native#text/pascal
tests/test/tcustomattr4.pp svneol=native#text/pascal

View File

@ -436,6 +436,7 @@ implementation
begin
consume(_LECKKLAMMER);
repeat
{ Parse attribute type }
p:=factor(false,[ef_type_only,ef_check_attr_suffix]);
if p.nodetype=typen then
@ -515,6 +516,8 @@ implementation
end;
p.free;
until not try_to_consume(_COMMA);
consume(_RECKKLAMMER);
end;

View File

@ -0,0 +1,40 @@
program tcustomattr19;
{$mode objfpc}
{$modeswitch prefixedattributes}
uses
TypInfo;
type
TTestAttribute = class(TCustomAttribute)
constructor Create;
constructor Create(aArg: LongInt);
end;
[TTestAttribute(42), TTest]
TMyTest = class
end;
var
at: PAttributeTable;
constructor TTestAttribute.Create;
begin
end;
constructor TTestAttribute.Create(aArg: LongInt);
begin
end;
begin
at := GetAttributeTable(TMyTest.ClassInfo);
if not Assigned(at) then
Halt(1);
if at^.AttributeCount <> 2 then
Halt(2);
Writeln('ok');
end.