Browse Source

* Return an error if there is nothing in the class to bind a custom attribute to + test

git-svn-id: branches/joost/classattributes@22966 -
joost 13 years ago
parent
commit
d3ca6c94ea
6 changed files with 446 additions and 406 deletions
  1. 1 0
      .gitattributes
  2. 3 1
      compiler/msg/errore.msg
  3. 3 2
      compiler/msgidx.inc
  4. 399 403
      compiler/msgtxt.inc
  5. 2 0
      compiler/pdecobj.pas
  6. 38 0
      tests/test/tclassattribute7.pp

+ 1 - 0
.gitattributes

@@ -10485,6 +10485,7 @@ tests/test/tclassattribute3.pp svneol=native#text/plain
 tests/test/tclassattribute4.pp svneol=native#text/plain
 tests/test/tclassattribute5.pp svneol=native#text/plain
 tests/test/tclassattribute6.pp svneol=native#text/plain
+tests/test/tclassattribute7.pp svneol=native#text/plain
 tests/test/tclassinfo1.pp svneol=native#text/pascal
 tests/test/tclrprop.pp svneol=native#text/plain
 tests/test/tcmov1.pp svneol=native#text/plain

+ 3 - 1
compiler/msg/errore.msg

@@ -136,7 +136,7 @@ general_f_oserror=01025_F_Operating system error: $1
 #
 # Scanner
 #
-# 02091 is the last used one
+# 02092 is the last used one
 #
 % \section{Scanner messages.}
 % This section lists the messages that the scanner emits. The scanner takes
@@ -386,6 +386,8 @@ scan_w_unavailable_system_codepage=02091_W_Current system codepage "$1" is not a
 % The compiler is compiled with support for several codepages built-in.
 % The codepage of the operation system is not in that list. You will need to recompile
 % the compiler with support for this codepage.
+scan_e_unresolved_attribute=02092_E_Unresolved custom attribute: "$1".
+% A custom attribute is defined, but there is no identifier to bind it to.
 % \end{description}
 #
 # Parser

+ 3 - 2
compiler/msgidx.inc

@@ -113,6 +113,7 @@ const
   scanner_f_illegal_utf8_bom=02089;
   scanner_w_directive_ignored_on_target=02090;
   scan_w_unavailable_system_codepage=02091;
+  scan_e_unresolved_attribute=02092;
   parser_e_syntax_error=03000;
   parser_e_dont_nest_interrupt=03004;
   parser_w_proc_directive_ignored=03005;
@@ -943,9 +944,9 @@ const
   option_info=11024;
   option_help_pages=11025;
 
-  MsgTxtSize = 65908;
+  MsgTxtSize = 65951;
 
   MsgIdxMax : array[1..20] of longint=(
-    26,92,322,118,87,56,116,26,202,63,
+    26,93,322,118,87,56,116,26,202,63,
     53,20,1,1,1,1,1,1,1,1
   );

File diff suppressed because it is too large
+ 399 - 403
compiler/msgtxt.inc


+ 2 - 0
compiler/pdecobj.pas

@@ -1231,6 +1231,8 @@ implementation
               end;
             _END :
               begin
+                if assigned(current_rttiattributesdef) and (current_rttiattributesdef.get_attribute_count>0) then
+                  Message1(scan_e_unresolved_attribute,trtti_attribute(current_rttiattributesdef.rtti_attributes[0]).typesym.prettyname);
                 consume(_END);
                 break;
               end;

+ 38 - 0
tests/test/tclassattribute7.pp

@@ -0,0 +1,38 @@
+{ %fail }
+program tclassattribute7;
+
+{$mode objfpc}{$H+}
+
+uses
+  typinfo;
+
+type
+
+  { tmyt }
+
+  TMyt = class(TCustomAttribute)
+    constructor create;
+  end;
+
+type
+
+  { TMyObject }
+
+  TMyObject = class(TObject)
+  private
+    FInt: integer;
+  published
+    // Should fail because there is nothing to bind the custom attribute to.
+    [TMyt]
+  end;
+
+constructor TMyt.create;
+begin
+//
+end;
+
+
+begin
+//
+end.
+

Some files were not shown because too many files changed in this diff