浏览代码

* extend scanning of $modeswitch to support not only + and -, but also ON and OFF like other switches
+ added tests

git-svn-id: trunk@39280 -

svenbarth 7 年之前
父节点
当前提交
ff407c56d9
共有 7 个文件被更改,包括 128 次插入2 次删除
  1. 5 0
      .gitattributes
  2. 4 2
      compiler/scandir.pas
  3. 25 0
      tests/tbf/tb0257a.pp
  4. 25 0
      tests/tbf/tb0257b.pp
  5. 23 0
      tests/tbs/tb0645a.pp
  6. 23 0
      tests/tbs/tb0645b.pp
  7. 23 0
      tests/tbs/tb0645c.pp

+ 5 - 0
.gitattributes

@@ -10882,6 +10882,8 @@ tests/tbf/tb0255a.pp svneol=native#text/pascal
 tests/tbf/tb0255b.pp svneol=native#text/pascal
 tests/tbf/tb0255c.pp svneol=native#text/pascal
 tests/tbf/tb0256.pp svneol=native#text/pascal
+tests/tbf/tb0257a.pp svneol=native#text/pascal
+tests/tbf/tb0257b.pp svneol=native#text/pascal
 tests/tbf/ub0115.pp svneol=native#text/plain
 tests/tbf/ub0149.pp svneol=native#text/plain
 tests/tbf/ub0158a.pp svneol=native#text/plain
@@ -11531,6 +11533,9 @@ tests/tbs/tb0641.pp svneol=native#text/pascal
 tests/tbs/tb0642.pp svneol=native#text/pascal
 tests/tbs/tb0643.pp svneol=native#text/pascal
 tests/tbs/tb0644.pp svneol=native#text/pascal
+tests/tbs/tb0645a.pp svneol=native#text/pascal
+tests/tbs/tb0645b.pp svneol=native#text/pascal
+tests/tbs/tb0645c.pp svneol=native#text/pascal
 tests/tbs/tb205.pp svneol=native#text/plain
 tests/tbs/tb610.pp svneol=native#text/pascal
 tests/tbs/tb613.pp svneol=native#text/plain

+ 4 - 2
compiler/scandir.pas

@@ -976,8 +976,10 @@ unit scandir;
             current_scanner.skipspace;
             current_scanner.readstring;
             s:=pattern;
-            if c in ['+','-'] then
-              s:=s+current_scanner.readstate;
+            { don't combine the assignments to s as the method call will be
+              done before "pattern" is assigned to s and the method changes
+              "pattern" }
+            s:=s+current_scanner.readoptionalstate('+');
             if not SetCompileModeSwitch(s,false) then
               Message1(scan_w_illegal_switch,s)
           end;

+ 25 - 0
tests/tbf/tb0257a.pp

@@ -0,0 +1,25 @@
+{ %FAIL }
+
+unit tb0257a;
+
+{$mode delphi}
+{$modeswitch advancedrecords-}
+
+interface
+
+type
+  TTest = record
+    procedure Test;
+  end;
+
+implementation
+
+{ TTest }
+
+procedure TTest.Test;
+begin
+
+end;
+
+end.
+

+ 25 - 0
tests/tbf/tb0257b.pp

@@ -0,0 +1,25 @@
+{ %FAIL }
+
+unit tb0257b;
+
+{$mode delphi}
+{$modeswitch advancedrecords off}
+
+interface
+
+type
+  TTest = record
+    procedure Test;
+  end;
+
+implementation
+
+{ TTest }
+
+procedure TTest.Test;
+begin
+
+end;
+
+end.
+

+ 23 - 0
tests/tbs/tb0645a.pp

@@ -0,0 +1,23 @@
+unit tb0645a;
+
+{$mode objfpc}
+{$modeswitch advancedrecords}
+
+interface
+
+type
+  TTest = record
+    procedure Test;
+  end;
+
+implementation
+
+{ TTest }
+
+procedure TTest.Test;
+begin
+
+end;
+
+end.
+

+ 23 - 0
tests/tbs/tb0645b.pp

@@ -0,0 +1,23 @@
+unit tb0645b;
+
+{$mode objfpc}
+{$modeswitch advancedrecords+}
+
+interface
+
+type
+  TTest = record
+    procedure Test;
+  end;
+
+implementation
+
+{ TTest }
+
+procedure TTest.Test;
+begin
+
+end;
+
+end.
+

+ 23 - 0
tests/tbs/tb0645c.pp

@@ -0,0 +1,23 @@
+unit tb0645c;
+
+{$mode objfpc}
+{$modeswitch advancedrecords on}
+
+interface
+
+type
+  TTest = record
+    procedure Test;
+  end;
+
+implementation
+
+{ TTest }
+
+procedure TTest.Test;
+begin
+
+end;
+
+end.
+