diff options
author | Brian Paul <[email protected]> | 2008-08-05 20:12:50 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2008-08-05 20:57:17 -0600 |
commit | 6b888a10d37f43feae272d0927d087916e9e3c0d (patch) | |
tree | b80e44117439a1d1c29bc5149c61a5747165cc98 | |
parent | bf3040d4767702f09e042c58f0f5aa942ddb9a16 (diff) |
mesa: glsl: additional type checking for assignments, inequalities
-rw-r--r-- | src/mesa/shader/slang/slang_codegen.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 036196a8d2b..94497cd833e 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -2889,6 +2889,10 @@ _slang_assignment_compatible(slang_assemble_ctx *A, t0.spec._struct->a_name != t1.spec._struct->a_name) return GL_FALSE; + if (t0.spec.type == SLANG_SPEC_FLOAT && + t1.spec.type == SLANG_SPEC_BOOL) + return GL_FALSE; + #if 0 /* not used just yet - causes problems elsewhere */ if (t0.spec.type == SLANG_SPEC_INT && t1.spec.type == SLANG_SPEC_FLOAT) @@ -3237,6 +3241,18 @@ _slang_gen_compare(slang_assemble_ctx *A, slang_operation *oper, return NULL; } + if (oper->type != SLANG_OPER_EQUAL && + oper->type != SLANG_OPER_NOTEQUAL) { + /* <, <=, >, >= can only be used with scalars */ + if ((t0.spec.type != SLANG_SPEC_INT && + t0.spec.type != SLANG_SPEC_FLOAT) || + (t1.spec.type != SLANG_SPEC_INT && + t1.spec.type != SLANG_SPEC_FLOAT)) { + slang_info_log_error(A->log, "Illegal type(s) for inequality operator"); + return NULL; + } + } + n = new_node2(opcode, _slang_gen_operation(A, &oper->children[0]), _slang_gen_operation(A, &oper->children[1])); |