2
0
Эх сурвалжийг харах

* skip <type>(<expr>) in the cond. expression parser if eval is false

git-svn-id: trunk@29116 -
florian 10 жил өмнө
parent
commit
b7a1418065

+ 1 - 0
.gitattributes

@@ -10307,6 +10307,7 @@ tests/tbs/tb0604.pp svneol=native#text/pascal
 tests/tbs/tb0605.pp svneol=native#text/pascal
 tests/tbs/tb0606.pp svneol=native#text/pascal
 tests/tbs/tb0607.pp svneol=native#text/plain
+tests/tbs/tb0608.pp svneol=native#text/pascal
 tests/tbs/tb205.pp svneol=native#text/plain
 tests/tbs/tbs0594.pp svneol=native#text/pascal
 tests/tbs/ub0060.pp svneol=native#text/plain

+ 31 - 14
compiler/scanner.pas

@@ -1912,21 +1912,38 @@ type
                     { first look for a macros/int/float }
                     result:=preproc_substitutedtoken(storedpattern,eval);
                     if eval and (result.consttyp=conststring) then
-                      if searchsym(storedpattern,srsym,srsymtable) then
+                      begin
+                        if searchsym(storedpattern,srsym,srsymtable) then
+                          begin
+                            try_consume_nestedsym(srsym,srsymtable);
+                            if assigned(srsym) then
+                              case srsym.typ of
+                                constsym:
+                                  begin
+                                    result.free;
+                                    result:=texprvalue.create_const(tconstsym(srsym));
+                                  end;
+                                enumsym:
+                                  begin
+                                    result.free;
+                                    result:=texprvalue.create_int(tenumsym(srsym).value);
+                                  end;
+                              end;
+                          end
+                        end
+                      { skip id(<expr>) if expression must not be evaluated }
+                      else if not(eval) and (result.consttyp=conststring) then
                         begin
-                          try_consume_nestedsym(srsym,srsymtable);
-                          if assigned(srsym) then
-                            case srsym.typ of
-                              constsym:
-                                begin
-                                  result.free;
-                                  result:=texprvalue.create_const(tconstsym(srsym));
-                                end;
-                              enumsym:
-                                begin
-                                  result.free;
-                                  result:=texprvalue.create_int(tenumsym(srsym).value);
-                                end;
+                          if current_scanner.preproc_token =_LKLAMMER then
+                            begin
+                              preproc_consume(_LKLAMMER);
+                              current_scanner.skipspace;
+
+                              result:=preproc_factor(false);
+                              if current_scanner.preproc_token =_RKLAMMER then
+                                preproc_consume(_RKLAMMER)
+                              else
+                                Message(scan_e_error_in_preproc_expr);
                             end;
                         end;
                   end

+ 9 - 0
tests/tbs/tb0608.pp

@@ -0,0 +1,9 @@
+const
+    c   = {$IF Declared(o) And (o<>Integer(0))}Succ{$IFEND}(False);
+
+  begin
+    if c then
+      halt(1);
+    writeln('ok');
+  end.
+