}
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=='/')
{
vec3 v;
m*m;
v*m;
+ ivec3 iv;
+ i<<iv;
}
/* Expected error:
<test>:10: No matching operator '/' found for 'int' and 'float'
<test>:13: No matching operator '*' found for 'mat3x2' and 'mat3x2'
<test>:14: No matching operator '*' found for 'vec3' and 'mat3x2'
+<test>:16: No matching operator '<<' found for 'int' and 'ivec3'
*/