git-svn-id: svn+ssh://svn.cprover.org/srv/svn/cbmc/trunk@42 6afb6bc1-c8e4-404c-8f48-9ae832c5b171
This commit is contained in:
parent
60d37f58fd
commit
a1fa707d10
|
@ -1371,12 +1371,6 @@ void c_typecheck_baset::typecheck_expr_trinary(if_exprt &expr)
|
|||
implicit_typecast(operands[2], expr.type());
|
||||
}
|
||||
|
||||
if(follow(operands[1].type())==follow(operands[2].type()))
|
||||
{
|
||||
expr.type()=operands[1].type();
|
||||
return;
|
||||
}
|
||||
|
||||
if(operands[1].type().id()==ID_empty ||
|
||||
operands[2].type().id()==ID_empty)
|
||||
{
|
||||
|
@ -1384,6 +1378,21 @@ void c_typecheck_baset::typecheck_expr_trinary(if_exprt &expr)
|
|||
return;
|
||||
}
|
||||
|
||||
if(follow(operands[1].type())==follow(operands[2].type()))
|
||||
{
|
||||
expr.type()=operands[1].type();
|
||||
|
||||
// GCC says: "A conditional expression is a valid lvalue
|
||||
// if its type is not void and the true and false branches
|
||||
// are both valid lvalues."
|
||||
|
||||
if(operands[1].get_bool(ID_C_lvalue) &&
|
||||
operands[2].get_bool(ID_C_lvalue))
|
||||
expr.set(ID_C_lvalue, true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
err_location(expr);
|
||||
str << "operator ?: not defined for types `"
|
||||
<< to_string(o_type1) << "' and `"
|
||||
|
|
Loading…
Reference in New Issue