Browse Source

fcl-passrc: fixed $warn identifier error

mattias 6 years ago
parent
commit
f9ec6a2196

+ 1 - 3
compiler/packages/fcl-passrc/src/pscanner.pp

@@ -3273,10 +3273,8 @@ begin
       DoLog(mtWarning,nIllegalStateForWarnDirective,SIllegalStateForWarnDirective,[Identifier]);
       exit;
       end;
-    end;
-
-  if Number>=0 then
     SetWarnMsgState(Number,State);
+    end;
 end;
 
 procedure TPascalScanner.HandleDefine(Param: String);

+ 42 - 14
compiler/packages/pastojs/src/fppas2js.pp

@@ -6749,9 +6749,7 @@ begin
           Result:=Call;
           exit;
           end;
-        eopAnd,
-        eopOr,
-        eopXor:
+        eopAnd:
           begin
           if aResolver<>nil then
             begin
@@ -6767,19 +6765,49 @@ begin
             UseBitwiseOp:=(GetExpressionValueType(El.left,AContext)=jstNumber)
               or (GetExpressionValueType(El.right,AContext)=jstNumber);
           if UseBitwiseOp then
-            Case El.OpCode of
-              eopAnd : C:=TJSBitwiseAndExpression;
-              eopOr : C:=TJSBitwiseOrExpression;
-              eopXor : C:=TJSBitwiseXOrExpression;
+            C:=TJSBitwiseAndExpression
+          else
+            C:=TJSLogicalAndExpression;
+          end;
+        eopOr:
+          begin
+          if aResolver<>nil then
+            begin
+            UseBitwiseOp:=((LeftResolved.BaseType in btAllJSInteger)
+                       or (RightResolved.BaseType in btAllJSInteger));
+            if UseBitwiseOp
+                and ((LeftResolved.BaseType in [btIntDouble,btUIntDouble])
+                  or (RightResolved.BaseType in [btIntDouble,btUIntDouble])) then
+              aResolver.LogMsg(20190228220145,mtWarning,nBitWiseOperationsAre32Bit,
+                sBitWiseOperationsAre32Bit,[],El);
             end
           else
-            Case El.OpCode of
-              eopAnd : C:=TJSLogicalAndExpression;
-              eopOr : C:=TJSLogicalOrExpression;
-              eopXor : C:=TJSBitwiseXOrExpression;
-            else
-              DoError(20161024191234,nBinaryOpcodeNotSupported,sBinaryOpcodeNotSupported,['logical XOR'],El);
-            end;
+            UseBitwiseOp:=(GetExpressionValueType(El.left,AContext)=jstNumber)
+              or (GetExpressionValueType(El.right,AContext)=jstNumber);
+          if UseBitwiseOp then
+            C:=TJSBitwiseOrExpression
+          else
+            C:=TJSLogicalOrExpression;
+          end;
+        eopXor:
+          begin
+          if aResolver<>nil then
+            begin
+            UseBitwiseOp:=((LeftResolved.BaseType in btAllJSInteger)
+                       or (RightResolved.BaseType in btAllJSInteger));
+            if UseBitwiseOp
+                and ((LeftResolved.BaseType in [btIntDouble,btUIntDouble])
+                  or (RightResolved.BaseType in [btIntDouble,btUIntDouble])) then
+              aResolver.LogMsg(20190228220225,mtWarning,nBitWiseOperationsAre32Bit,
+                sBitWiseOperationsAre32Bit,[],El);
+            end
+          else
+            UseBitwiseOp:=(GetExpressionValueType(El.left,AContext)=jstNumber)
+              or (GetExpressionValueType(El.right,AContext)=jstNumber);
+          if UseBitwiseOp then
+            C:=TJSBitwiseXOrExpression
+          else
+            C:=TJSBitwiseXOrExpression;
           end;
         eopPower:
           begin