aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl/ir_constant_expression.cpp
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2015-12-30 14:48:22 -0500
committerMatt Turner <[email protected]>2016-01-13 11:22:11 -0800
commita5fcff6628c641d01954d0af4aee0e723a570cad (patch)
tree27fedf5616021c31b2f1aa4b130892cbf513af1e /src/glsl/ir_constant_expression.cpp
parent966a0dd72066cc98e0df9a02028ee0d85d466e26 (diff)
glsl: Fix undefined shifts.
Shifting into the sign bit is undefined, as is shifting by 32. Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/glsl/ir_constant_expression.cpp')
-rw-r--r--src/glsl/ir_constant_expression.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp
index 7613139306f..c99a8239cbb 100644
--- a/src/glsl/ir_constant_expression.cpp
+++ b/src/glsl/ir_constant_expression.cpp
@@ -1539,10 +1539,10 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
data.i[c] = -1;
else {
int count = 0;
- int top_bit = op[0]->type->base_type == GLSL_TYPE_UINT
- ? 0 : v & (1 << 31);
+ unsigned top_bit = op[0]->type->base_type == GLSL_TYPE_UINT
+ ? 0 : v & (1u << 31);
- while (((v & (1 << 31)) == top_bit) && count != 32) {
+ while (((v & (1u << 31)) == top_bit) && count != 32) {
count++;
v <<= 1;
}
@@ -1721,7 +1721,7 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
else if (offset + bits > 32)
data.u[c] = 0; /* Undefined, per spec. */
else {
- unsigned insert_mask = ((1 << bits) - 1) << offset;
+ unsigned insert_mask = ((1ull << bits) - 1) << offset;
unsigned insert = op[1]->value.u[c];
insert <<= offset;