Browse Source

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

git-svn-id: trunk@41724 -
Jonas Maebe 6 years ago
parent
commit
bde560dac2
3 changed files with 18 additions and 2 deletions
  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/tw3479.pp svneol=native#text/plain
 tests/webtbs/tw34818.pp svneol=native#text/pascal
 tests/webtbs/tw34818.pp svneol=native#text/pascal
 tests/webtbs/tw34848.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/tw3489.pp svneol=native#text/plain
 tests/webtbs/tw34893.pp -text svneol=native#text/pascal
 tests/webtbs/tw34893.pp -text svneol=native#text/pascal
 tests/webtbs/tw3490.pp svneol=native#text/plain
 tests/webtbs/tw3490.pp svneol=native#text/plain

+ 2 - 2
compiler/scanner.pas

@@ -3833,14 +3833,14 @@ type
         valuedescr: String;
         valuedescr: String;
       begin
       begin
         if assigned(preprocstack) and
         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
          begin
            { when the branch is accepted we use pp_elseif so we know that
            { 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
              all the next branches need to be rejected. when this branch is still
              not accepted then leave it at pp_if }
              not accepted then leave it at pp_if }
            if (preprocstack.typ=pp_elseif) then
            if (preprocstack.typ=pp_elseif) then
              preprocstack.accept:=false
              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
                begin
                  preprocstack.accept:=false;
                  preprocstack.accept:=false;
                  preprocstack.typ:=pp_elseif;
                  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.