mixed types with BO_Sh[rl]


in a simple expression like:

  unsigned int _x;

  return (_x >> 30);

the BinaryOperator is formed like this:

(BinaryOperator 0x8018dc1a0 'unsigned int' '>>'
  (DeclRefExpr 0x8018dc140 'unsigned int' lvalue Var='_x' 0x80188ff70)
  (IntegerLiteral 0x8018dc170 'int' 30))

note the mixed operands with 'unsigned int' and 'int' types.

Is this by design or by mistake? I guess there should be IntegralCast
for the 'int' 30, right? This happens only for Shr/Shl operators,
all others have the IntegralCast I would expect here.

thank you, roman

Hi Roman,

This is actually by design. C doesn't constrain the shift amount to be the same type as the LHS of the shift.