* don't bother finding the correct constructor if the attribute isn't a TCustomAttribute descendant anyway; simply skip the parameters in that case

+ added tests

git-svn-id: trunk@42470 -
This commit is contained in:
svenbarth 2019-07-20 19:46:03 +00:00
parent 6cde8ab4cb
commit c282f21b1b
4 changed files with 48 additions and 1 deletions

2
.gitattributes vendored
View File

@ -13218,6 +13218,8 @@ 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/tcustomattr20.pp svneol=native#text/pascal
tests/test/tcustomattr21.pp svneol=native#text/pascal
tests/test/tcustomattr3.pp svneol=native#text/pascal
tests/test/tcustomattr4.pp svneol=native#text/pascal
tests/test/tcustomattr5.pp svneol=native#text/pascal

View File

@ -447,7 +447,11 @@ implementation
{ Check if the attribute class is related to TCustomAttribute }
if not is_system_custom_attribute_descendant(od) then
incompatibletypes(od,class_tcustomattribute);
begin
incompatibletypes(od,class_tcustomattribute);
read_attr_paras.free;
continue;
end;
paran:=read_attr_paras;

View File

@ -0,0 +1,15 @@
{ %FAIL }
program tcustomattr20;
{$mode objfpc}{$H+}
{$modeswitch prefixedattributes}
type
{ ensure that arguments of non existing attributes are skipped correctly }
[TMyAttributeDoesNotExist('Alpha', 42)]
TMyObject = class(TObject)
end;
begin
end.

View File

@ -0,0 +1,26 @@
{ %fail }
program tcustomattr21;
{$mode objfpc}{$H+}
{$modeswitch prefixedattributes}
type
{ tmyt }
tmyt = class
constructor create;
end;
{ ensure that arguments are skipped correctly }
[tmyt('Alpha', 42)]
TMyObject = class(TObject)
end;
constructor tmyt.create;
begin
end;
begin
end.