Generate errors for empty constructors instead of asserting
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 23 Jun 2010 20:58:34 +0000 (13:58 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 23 Jun 2010 20:58:34 +0000 (13:58 -0700)
This causes the following tests to pass:

     glslparsertest/glsl2/constructor-10.vert

ast_function.cpp

index 691e6aeba00f9864fa63b9c46332274463aadbf4..ff2dfa502f3c6044d3337fe577cf70a9b4c2927b 100644 (file)
@@ -513,7 +513,14 @@ ast_function_expression::hir(exec_list *instructions,
 
         bool all_parameters_are_constant = true;
 
-        assert(!this->expressions.is_empty());
+        /* This handles invalid constructor calls such as 'vec4 v = vec4();'
+         */
+        if (this->expressions.is_empty()) {
+           _mesa_glsl_error(& loc, state, "too few components to construct "
+                            "`%s'",
+                            constructor_type->name);
+           return ir_call::get_error_instruction();
+        }
 
         foreach_list (n, &this->expressions) {
            ast_node *ast = exec_node_data(ast_node, n, link);