2
0
Эх сурвалжийг харах

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

svenbarth 6 жил өмнө
parent
commit
c282f21b1b

+ 2 - 0
.gitattributes

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

+ 5 - 1
compiler/pdecl.pas

@@ -447,7 +447,11 @@ implementation
 
 
               { Check if the attribute class is related to TCustomAttribute }
               { Check if the attribute class is related to TCustomAttribute }
               if not is_system_custom_attribute_descendant(od) then
               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;
               paran:=read_attr_paras;
 
 

+ 15 - 0
tests/test/tcustomattr20.pp

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

+ 26 - 0
tests/test/tcustomattr21.pp

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