Fix bug related to support of SAFE datatypes.
authorMario de Sousa <msousa@fe.up.pt>
Thu, 11 Oct 2012 19:16:35 +0100
changeset 675 59fc28d4b06c
parent 674 b221168a36f1
child 676 ca4f17211251
Fix bug related to support of SAFE datatypes.
stage3/narrow_candidate_datatypes.cc
--- a/stage3/narrow_candidate_datatypes.cc	Sun Oct 07 09:45:54 2012 +0100
+++ b/stage3/narrow_candidate_datatypes.cc	Thu Oct 11 19:16:35 2012 +0100
@@ -863,15 +863,17 @@
 				set_datatype_in_prev_il_instructions(prev_instruction_type, fake_prev_il_instruction);
 				/* set the datatype for the operand */
 				il_operand->datatype = operand_type;
+				il_operand->accept(*this);
 				
-				count ++;
+				/* NOTE: DO NOT search any further! Return immediately!
+				 * Since we support SAFE*** datatypes, multiple entries in the widen_table may be compatible.
+				 * If we try to set more than one distinct datatype on the same symbol, then the datatype will be set to
+				 * an invalid_datatype, which is NOT what we want!
+				 */
+				return NULL;
 			}
 		}
 	}
-// 	if (count > 1) ERROR; /* Since we also support SAFE data types, this assertion is not necessarily always tru! */
-	if (is_type_valid(symbol->datatype) && (count <= 0)) ERROR;
-
-	il_operand->accept(*this);
 	return NULL;
 }