Browse Source

* fix #40592: make the Delphi-compatible attributes usable, but in a way that makes it clear to the user that they won't work
+ added test

Sven/Sarah Barth 1 năm trước cách đây
mục cha
commit
dd4f7e9148
3 tập tin đã thay đổi với 41 bổ sung4 xóa
  1. 12 0
      rtl/inc/objpas.inc
  2. 10 4
      rtl/inc/objpash.inc
  3. 19 0
      tests/webtbs/tw40592.pp

+ 12 - 0
rtl/inc/objpas.inc

@@ -1308,6 +1308,18 @@ end;
       inherited;
       inherited;
     end;
     end;
 
 
+
+{****************************************************************************
+                               TCustomAttribute
+****************************************************************************}
+
+
+    constructor TUnimplementedAttribute.Create;
+    begin
+      inherited;
+    end;
+
+
 {****************************************************************************
 {****************************************************************************
                                TCustomStoredAttribute
                                TCustomStoredAttribute
 ****************************************************************************}
 ****************************************************************************}

+ 10 - 4
rtl/inc/objpash.inc

@@ -502,10 +502,16 @@
          constructor Create;
          constructor Create;
        end;
        end;
        {$POP}
        {$POP}
-       WeakAttribute = class(TCustomAttribute);
-       UnsafeAttribute = class(TCustomAttribute);
-       RefAttribute = class(TCustomAttribute);
-       VolatileAttribute = class(TCustomAttribute);
+
+       TUnimplementedAttribute = class(TCustomAttribute)
+       public
+         constructor Create; unimplemented;
+       end;
+
+       WeakAttribute = class(TUnimplementedAttribute);
+       UnsafeAttribute = class(TUnimplementedAttribute);
+       RefAttribute = class(TUnimplementedAttribute);
+       VolatileAttribute = class(TUnimplementedAttribute);
 
 
        StoredAttribute = Class(TCustomAttribute)
        StoredAttribute = Class(TCustomAttribute)
        Private
        Private

+ 19 - 0
tests/webtbs/tw40592.pp

@@ -0,0 +1,19 @@
+{ %NORUN }
+
+program tw40592;
+
+{$mode objfpc}
+{$modeswitch prefixedattributes}
+
+type
+  [Volatile]
+  [Unsafe]
+  [Weak]
+  [Ref]
+  TTest = class
+
+  end;
+
+begin
+
+end.