From aeb3caeba5be5897bce4c25b84496a171711952b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 26 Nov 2008 09:35:26 -0700 Subject: mesa: add missing type check for function calls (cherry picked from commit 001b1cbb0dacf76dd09cda56840c30226abd3534) --- src/mesa/shader/slang/slang_codegen.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/mesa/shader/slang') diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 958f9bd777a..b821122663c 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -2025,6 +2025,21 @@ _slang_gen_function_call_name(slang_assemble_ctx *A, const char *name, return NULL; } + /* type checking to be sure function's return type matches 'dest' type */ + if (dest) { + slang_typeinfo t0; + + slang_typeinfo_construct(&t0); + _slang_typeof_operation(A, dest, &t0); + + if (!slang_type_specifier_equal(&t0.spec, &fun->header.type.specifier)) { + slang_info_log_error(A->log, + "Incompatible type returned by call to '%s'", + name); + return NULL; + } + } + n = _slang_gen_function_call(A, fun, oper, dest); if (n && !n->Store && !dest -- cgit v1.2.3