Browse Source

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 years ago
parent
commit
e38bb96c61
1 changed files with 5 additions and 1 deletions
  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)
 							OR (expressionType IS SyntaxTree.EnumerationType)
 							) 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
 							Error(left.position,"invalid type in explicit conversion");
 						END;