}
else if((oper=='<' || oper=='>') && oper2==oper)
{
- // Shifts only apply to integers.
- if(basic_left->kind!=BasicTypeDeclaration::INT || basic_right->kind!=BasicTypeDeclaration::INT)
+ // Shifts apply to integer scalars and vectors, with some restrictions.
+ if(elem_left->kind!=BasicTypeDeclaration::INT || elem_right->kind!=BasicTypeDeclaration::INT)
+ return;
+ unsigned left_size = (basic_left->kind==BasicTypeDeclaration::INT ? 1 : basic_left->kind==BasicTypeDeclaration::VECTOR ? basic_left->size : 0);
+ unsigned right_size = (basic_right->kind==BasicTypeDeclaration::INT ? 1 : basic_right->kind==BasicTypeDeclaration::VECTOR ? basic_right->size : 0);
+ if(!left_size || (left_size==1 && right_size!=1) || (left_size>1 && right_size!=1 && right_size!=left_size))
return;
type = basic_left;
+ // Don't perform conversion even if the operands are of different sizes.
+ compat = SAME_TYPE;
}
else if(oper=='+' || oper=='-' || oper=='*' || oper=='/')
{