summaryrefslogtreecommitdiff
path: root/ast_function.cpp
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-04-02 15:51:02 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-04-02 15:51:02 -0700
commitc35bb00130a3f400af1ab9c5eff555c4f9e143d2 (patch)
tree65a45a35fe0dc03c8ec026468546115b3225a2bf /ast_function.cpp
parentcf37c9e8dad4349e45cb91d36957484fd76ce264 (diff)
Ensure that 'in' and 'inout' formal parameters are valid lvalues
This causes the following tests to pass: glslparsertest/shaders/function10.frag
Diffstat (limited to 'ast_function.cpp')
-rw-r--r--ast_function.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/ast_function.cpp b/ast_function.cpp
index 09b7879..2869837 100644
--- a/ast_function.cpp
+++ b/ast_function.cpp
@@ -63,6 +63,37 @@ process_call(exec_list *instructions, ir_function *f,
(void) instructions;
if (sig != NULL) {
+ /* Verify that 'out' and 'inout' actual parameters are lvalues. This
+ * isn't done in ir_function::matching_signature because that function
+ * cannot generate the necessary diagnostics.
+ */
+ exec_list_iterator actual_iter = actual_parameters->iterator();
+ exec_list_iterator formal_iter = sig->parameters.iterator();
+
+ while (actual_iter.has_next()) {
+ ir_rvalue *actual =
+ ((ir_instruction *) actual_iter.get())->as_rvalue();
+ ir_variable *formal =
+ ((ir_instruction *) formal_iter.get())->as_variable();
+
+ assert(actual != NULL);
+ assert(formal != NULL);
+
+ if ((formal->mode == ir_var_out)
+ || (formal->mode == ir_var_inout)) {
+ if (! actual->is_lvalue()) {
+ /* FINISHME: Log a better diagnostic here. There is no way
+ * FINISHME: to tell the user which parameter is invalid.
+ */
+ _mesa_glsl_error(loc, state, "`%s' parameter is not lvalue",
+ (formal->mode == ir_var_out) ? "out" : "inout");
+ }
+ }
+
+ actual_iter.next();
+ formal_iter.next();
+ }
+
/* FINISHME: The list of actual parameters needs to be modified to
* FINISHME: include any necessary conversions.
*/