浏览代码

* also accept {$elsif} after {$if(n)def} (mantis #34858)

git-svn-id: trunk@41724 -
Jonas Maebe 6 年之前
父节点
当前提交
bde560dac2
共有 3 个文件被更改,包括 18 次插入2 次删除
  1. 1 0
      .gitattributes
  2. 2 2
      compiler/scanner.pas
  3. 15 0
      tests/webtbs/tw34858.pp

+ 1 - 0
.gitattributes

@@ -16549,6 +16549,7 @@ tests/webtbs/tw3478.pp svneol=native#text/plain
 tests/webtbs/tw3479.pp svneol=native#text/plain
 tests/webtbs/tw34818.pp svneol=native#text/pascal
 tests/webtbs/tw34848.pp svneol=native#text/pascal
+tests/webtbs/tw34858.pp svneol=native#text/plain
 tests/webtbs/tw3489.pp svneol=native#text/plain
 tests/webtbs/tw34893.pp -text svneol=native#text/pascal
 tests/webtbs/tw3490.pp svneol=native#text/plain

+ 2 - 2
compiler/scanner.pas

@@ -3833,14 +3833,14 @@ type
         valuedescr: String;
       begin
         if assigned(preprocstack) and
-           (preprocstack.typ in [pp_if,pp_elseif]) then
+           (preprocstack.typ in [pp_if,pp_ifdef,pp_ifndef,pp_elseif]) then
          begin
            { when the branch is accepted we use pp_elseif so we know that
              all the next branches need to be rejected. when this branch is still
              not accepted then leave it at pp_if }
            if (preprocstack.typ=pp_elseif) then
              preprocstack.accept:=false
-           else if (preprocstack.typ=pp_if) and preprocstack.accept then
+           else if (preprocstack.typ in [pp_if,pp_ifdef,pp_ifndef]) and preprocstack.accept then
                begin
                  preprocstack.accept:=false;
                  preprocstack.typ:=pp_elseif;

+ 15 - 0
tests/webtbs/tw34858.pp

@@ -0,0 +1,15 @@
+{ %norun }
+
+const a = 6;
+{$IFDEF ENDIAN_LITTLE}
+const b = 7;
+{$ELSEIF a > 5}
+const b = 7;
+{$ELSE}
+  {$ERROR Unknown endian}
+{$IFEND}
+
+begin
+  if b<>7 then
+    halt(1);
+end.