Parcourir la source

* fix precedence of IS operator, resolves #35909

git-svn-id: trunk@44266 -
florian il y a 5 ans
Parent
commit
bc3131688a
4 fichiers modifiés avec 16 ajouts et 3 suppressions
  1. 1 0
      .gitattributes
  2. 2 2
      compiler/tokens.pas
  3. 1 1
      packages/fcl-report/src/fpreport.pp
  4. 12 0
      tests/webtbf/tw35909.pp

+ 1 - 0
.gitattributes

@@ -16221,6 +16221,7 @@ tests/webtbf/tw35671.pp svneol=native#text/plain
 tests/webtbf/tw35753.pp svneol=native#text/plain
 tests/webtbf/tw3583.pp svneol=native#text/plain
 tests/webtbf/tw35866.pp svneol=native#text/pascal
+tests/webtbf/tw35909.pp svneol=native#text/pascal
 tests/webtbf/tw35981.pp svneol=native#text/pascal
 tests/webtbf/tw36114.pp svneol=native#text/pascal
 tests/webtbf/tw36223.pp svneol=native#text/pascal

+ 2 - 2
compiler/tokens.pas

@@ -344,10 +344,10 @@ const
 
   { Warning these stay be ordered !! }
   operator_levels:array[Toperator_precedence] of set of NOTOKEN..last_operator=
-      ([_LT,_LTE,_GT,_GTE,_EQ,_NE,_OP_IN],
+      ([_LT,_LTE,_GT,_GTE,_EQ,_NE,_OP_IN,_OP_IS],
        [_PLUS,_MINUS,_OP_OR,_PIPE,_OP_XOR],
        [_CARET,_SYMDIF,_STARSTAR,_STAR,_SLASH,
-        _OP_AS,_OP_IS,_OP_AND,_AMPERSAND,_OP_DIV,_OP_MOD,_OP_SHL,_OP_SHR],
+        _OP_AS,_OP_AND,_AMPERSAND,_OP_DIV,_OP_MOD,_OP_SHL,_OP_SHR],
        [_STARSTAR] );
 
 type

+ 1 - 1
packages/fcl-report/src/fpreport.pp

@@ -12283,7 +12283,7 @@ begin
       if CurrentLoop.FGroupHeaderList.Count > 0 then
       begin
         { when data band overflows use start with lowest gropup header }
-        if aBand is TFPReportCustomDataBand and
+        if (aBand is TFPReportCustomDataBand) and
         not Assigned(TFPReportCustomDataBand(aband).MasterBand) then
           lToMoveGrp := TFPReportCustomGroupHeaderBand(CurrentLoop.FGroupHeaderList[0])
         { when group header overflows use start with parent group header }

+ 12 - 0
tests/webtbf/tw35909.pp

@@ -0,0 +1,12 @@
+{ %fail% }
+{$mode delphi}
+program IS_Precedence;
+uses
+  Classes;
+var
+  O1, O2: TObject;
+begin
+  O1 := TComponent.Create(nil);
+  O2 := TObject.Create;
+  Writeln(O1 is TComponent or O2 is TComponent); // <<< should not compile because OR has precedence before IS
+end.