Browse Source

* formatting
+ test for issue #41066 which was already resolved previously

florian 7 months ago
parent
commit
553a1b968d
2 changed files with 49 additions and 5 deletions
  1. 5 5
      compiler/pdecobj.pas
  2. 44 0
      tests/webtbs/tw41066.pp

+ 5 - 5
compiler/pdecobj.pas

@@ -1211,12 +1211,12 @@ implementation
                 object_member_blocktype:=bt_type;
                 object_member_blocktype:=bt_type;
 
 
                 if (token=_LECKKLAMMER) and (m_prefixed_attributes in current_settings.modeswitches) then
                 if (token=_LECKKLAMMER) and (m_prefixed_attributes in current_settings.modeswitches) then
-                begin
-                  check_unbound_attributes;
-                  types_dec(true,hadgeneric, rtti_attrs_def);
-                end
+                  begin
+                    check_unbound_attributes;
+                    types_dec(true,hadgeneric, rtti_attrs_def);
+                  end
                 else
                 else
-                  // expect at least one type declaration
+                  { expect at least one type declaration }
                   if token<>_ID then
                   if token<>_ID then
                     consume(_ID);
                     consume(_ID);
               end;
               end;

+ 44 - 0
tests/webtbs/tw41066.pp

@@ -0,0 +1,44 @@
+program Project1;
+
+{$mode objfpc}{$H+}
+{$modeswitch prefixedattributes}
+
+
+uses
+  Classes;
+
+type
+
+  { TMyAttribute }
+
+  TMyAttribute = class(TCustomAttribute)
+    constructor Create(AVal: Boolean);
+  private
+    FVal: Boolean;
+  published
+    property Val: Boolean read FVal;
+  end;
+
+  TMyObject = class
+  public
+    type
+      TFoobar = (fbOne, fbTwo);
+      [TMyAttribute(False)] // this works fine
+      TFoo = (fooOne, fooTwo);
+  public
+    type
+      [TMyAttribute(False)] // project1.lpr(30,7) Error: Syntax error, "identifier" expected but "[" found
+      TBar = (barOne, barTwo);
+  end;
+
+{ TMyAttribute }
+
+constructor TMyAttribute.Create(AVal: Boolean);
+begin
+  FVal := AVal;
+
+end;
+
+begin
+
+end.