Custom attribute as first item of TClass type section fails to compile [PATCH]
Summary
Compiler fails when a a custom attribute is the first item in a TObject type section
Free Pascal Compiler version 3.3.1 [2024/10/19] for x86_64 (37b7835b)
Patch
prefixed_attribute_in_class_type.patch this seems to fix it.
System Information
- Operating system: Linux
- Processor architecture: x86-64
- Compiler version: 3.3.1 [2024/10/19] for x86_64 (37b7835b)
- Device: Computer
Steps to reproduce
Example project
Example Project
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.
Fails with
Hint: (11030) Start of reading config file /etc/fpc.cfg
Hint: (11031) End of reading config file /etc/fpc.cfg
Free Pascal Compiler version 3.3.1 [2024/10/19] for x86_64
Copyright (c) 1993-2024 by Florian Klaempfl and others
(1002) Target OS: Linux for x86-64
(3104) Compiling /home/andrew/tmp/project1.lpr
/home/andrew/tmp/project1.lpr(30,7) Fatal: (2003) Syntax error, "identifier" expected but "[" found
Fatal: (1018) Compilation aborted
Edited by Andrew Haines