浏览代码

* don't allow multiple deprecated messages, resolves #21466

git-svn-id: trunk@20515 -
florian 13 年之前
父节点
当前提交
fbc519faeb
共有 3 个文件被更改,包括 16 次插入0 次删除
  1. 1 0
      .gitattributes
  2. 6 0
      compiler/pmodules.pas
  3. 9 0
      tests/webtbf/tw21466.pas

+ 1 - 0
.gitattributes

@@ -11320,6 +11320,7 @@ tests/webtbf/tw21078.pp svneol=native#text/plain
 tests/webtbf/tw21087.pp svneol=native#text/plain
 tests/webtbf/tw2128.pp svneol=native#text/plain
 tests/webtbf/tw2129.pp svneol=native#text/plain
+tests/webtbf/tw21466.pas svneol=native#text/pascal
 tests/webtbf/tw2154.pp svneol=native#text/plain
 tests/webtbf/tw2174.pp svneol=native#text/plain
 tests/webtbf/tw2209.pp svneol=native#text/plain

+ 6 - 0
compiler/pmodules.pas

@@ -1015,9 +1015,11 @@ implementation
 
     function try_consume_hintdirective(var moduleopt:tmoduleoptions; var deprecatedmsg:pshortstring):boolean;
       var
+        deprecated_seen,
         last_is_deprecated:boolean;
       begin
         try_consume_hintdirective:=false;
+        deprecated_seen:=false;
         repeat
           last_is_deprecated:=false;
           case idtoken of
@@ -1028,9 +1030,13 @@ implementation
               end;
             _DEPRECATED :
               begin
+                { allow deprecated only once }
+                if deprecated_seen then
+                  break;
                 include(moduleopt,mo_hint_deprecated);
                 try_consume_hintdirective:=true;
                 last_is_deprecated:=true;
+                deprecated_seen:=true;
               end;
             _EXPERIMENTAL :
               begin

+ 9 - 0
tests/webtbf/tw21466.pas

@@ -0,0 +1,9 @@
+{ %fail }
+unit tw21466 deprecated 'blah blah' deprecated 'koko';
+
+interface
+
+implementation
+
+finalization
+end.