Browse Source

* disable [...] syntax for procedure directives if modeswitch "prefixed attributes" is enabled; they conflict otherwise and it's not easily resolveable
+ added test

git-svn-id: trunk@42402 -

svenbarth 6 years ago
parent
commit
a72553eea2
4 changed files with 38 additions and 2 deletions
  1. 2 0
      .gitattributes
  2. 7 2
      compiler/pdecsub.pas
  3. 14 0
      tests/test/tcustomattr15.pp
  4. 15 0
      tests/test/tcustomattr16.pp

+ 2 - 0
.gitattributes

@@ -13211,6 +13211,8 @@ tests/test/tcustomattr11.pp svneol=native#text/pascal
 tests/test/tcustomattr12.pp svneol=native#text/pascal
 tests/test/tcustomattr13.pp svneol=native#text/pascal
 tests/test/tcustomattr14.pp svneol=native#text/pascal
+tests/test/tcustomattr15.pp svneol=native#text/pascal
+tests/test/tcustomattr16.pp svneol=native#text/pascal
 tests/test/tcustomattr2.pp svneol=native#text/pascal
 tests/test/tcustomattr3.pp svneol=native#text/pascal
 tests/test/tcustomattr4.pp svneol=native#text/pascal

+ 7 - 2
compiler/pdecsub.pas

@@ -3277,9 +3277,14 @@ const
         else
           stoprecording:=false;
 
-        while token in [_ID,_LECKKLAMMER] do
+        while (token=_ID) or
+            (
+              not (m_prefixed_attributes in current_settings.modeswitches) and
+              (token=_LECKKLAMMER)
+            ) do
          begin
-           if try_to_consume(_LECKKLAMMER) then
+           if not (m_prefixed_attributes in current_settings.modeswitches) and
+              try_to_consume(_LECKKLAMMER) then
             begin
               repeat
                 parse_proc_direc(pd,pdflags);

+ 14 - 0
tests/test/tcustomattr15.pp

@@ -0,0 +1,14 @@
+{ %FAIL }
+
+{ prefixed attributes modeswitch disables procedure directives inside [...] }
+
+program tcustomattr15;
+
+{$mode delphi}
+
+procedure Test; [cdecl];
+begin
+end;
+
+begin
+end.

+ 15 - 0
tests/test/tcustomattr16.pp

@@ -0,0 +1,15 @@
+{ %FAIL }
+
+{ prefixed attributes modeswitch disables procedure directives inside [...] }
+
+program tcustomattr16;
+
+{$mode objfpc}
+{$modeswitch prefixedattributes}
+
+procedure Test; [cdecl];
+begin
+end;
+
+begin
+end.