codetools: ignore constant operand in operator comparison if the other operand has a defined type.

git-svn-id: trunk@50230 -
This commit is contained in:
ondrej 2015-11-05 06:21:21 +00:00
parent 9271bc1893
commit 1b015d1034

View File

@ -1485,7 +1485,16 @@ function TTypeAliasOrderList.Compare(const Operand1,
var
xCompRes: Integer;
begin
//first compare base types
// first check if one of the operands is a constant -> if yes, automatically
// return the other
// (x := f + 1; should return always type of f)
if (Operand1.Expr.Desc in xtAllConstTypes) and not (Operand2.Expr.Desc in xtAllConstTypes) then
Exit(Operand2)
else
if (Operand2.Expr.Desc in xtAllConstTypes) and not (Operand1.Expr.Desc in xtAllConstTypes) then
Exit(Operand1);
// then compare base types
xCompRes := Compare(
Tool.FindExprTypeAsString(Operand1.Expr, CleanPos, nil),
Tool.FindExprTypeAsString(Operand2.Expr, CleanPos, nil));