浏览代码

no conversion of float to unsigned data types

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@7590 8c9fc860-2736-0410-a75d-ab315db34111
felixf 7 年之前
父节点
当前提交
e38bb96c61
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      source/FoxSemanticChecker.Mod

+ 5 - 1
source/FoxSemanticChecker.Mod

@@ -6325,7 +6325,11 @@ TYPE
 							((expressionType IS SyntaxTree.NumberType) OR (expressionType IS SyntaxTree.AddressType) OR (expressionType IS SyntaxTree.SizeType)
 							((expressionType IS SyntaxTree.NumberType) OR (expressionType IS SyntaxTree.AddressType) OR (expressionType IS SyntaxTree.SizeType)
 							OR (expressionType IS SyntaxTree.EnumerationType)
 							OR (expressionType IS SyntaxTree.EnumerationType)
 							) THEN
 							) THEN
-							result := NewConversion(designator.position,expression,typeDeclaration.declaredType,left)
+							IF ((type IS SyntaxTree.AddressType) OR (type IS SyntaxTree.IntegerType) & (~type(SyntaxTree.IntegerType).signed)) & (expressionType IS SyntaxTree.FloatType) THEN
+								Error(left.position,"invalid unsigned type in explicit conversion");
+							ELSE
+								result := NewConversion(designator.position,expression,typeDeclaration.declaredType,left)
+							END;
 						ELSE
 						ELSE
 							Error(left.position,"invalid type in explicit conversion");
 							Error(left.position,"invalid type in explicit conversion");
 						END;
 						END;