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

Patched a case where integer was compared with unsafe pointer:
VAR x: ADDRESS; p: POINTER {UNSAFE} TO ARRAY OF CHAR;
IF SYSTEM.GET32(x) = p THEN ... END;

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@6656 8c9fc860-2736-0410-a75d-ab315db34111

felixf 9 жил өмнө
parent
commit
40f957ebe7

+ 5 - 0
source/FoxSemanticChecker.Mod

@@ -2558,6 +2558,8 @@ TYPE
 						OR ~(type IS SyntaxTree.ArrayType) THEN
 						Error(expression.position,Diagnostics.Invalid,"cannot convert array type to non-array type")
 					END;
+			ELSIF IsPointerType(type) & ~IsPointerType(expression.type.resolved) THEN
+				result := SyntaxTree.NewConversion(expression.position,expression,system.addressType,reference);
 			ELSIF ~(type IS SyntaxTree.BasicType) & ~(expression.type.resolved IS SyntaxTree.CharacterType) THEN
 				(*skip, no conversion*)
 			ELSIF (type IS SyntaxTree.ArrayType) & (type(SyntaxTree.ArrayType).arrayBase.resolved IS SyntaxTree.ByteType) THEN
@@ -2978,6 +2980,9 @@ TYPE
 					Error(binaryExpression.position,Diagnostics.Invalid,"incompatible operands");
 					IF VerboseErrorMessage THEN Printout.Info("leftType",leftType); Printout.Info("right",rightType) END
 				ELSIF (operator = Scanner.Equal) OR (operator = Scanner.Unequal) THEN
+					ConvertOperands(left, right);
+					binaryExpression.SetLeft(left);
+					binaryExpression.SetRight(right);
 					IF (left IS SyntaxTree.NilValue) & (right IS SyntaxTree.NilValue) THEN
 						IF operator = Scanner.Equal THEN NewBool(TRUE) ELSE NewBool(FALSE) END;
 					END;