summaryrefslogtreecommitdiffstats
path: root/ast_to_hir.cpp
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2010-04-02 15:30:45 -0700
committerIan Romanick <[email protected]>2010-04-02 15:30:45 -0700
commitcf37c9e8dad4349e45cb91d36957484fd76ce264 (patch)
treebf82ec510d3d9b945a5b7ecd705e49272c7687ec /ast_to_hir.cpp
parent45d8a70c12ee6ea956baaf898324a828496382f6 (diff)
Additional void parameter checks
If there is a void parameter it must not have a name, and it must be the only parameter.
Diffstat (limited to 'ast_to_hir.cpp')
-rw-r--r--ast_to_hir.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp
index 3fddd5f1961..cc985814db6 100644
--- a/ast_to_hir.cpp
+++ b/ast_to_hir.cpp
@@ -1625,14 +1625,21 @@ ast_parameter_declarator::hir(exec_list *instructions,
* for a function, which avoids tripping up checks for main taking
* parameters and lookups of an unnamed symbol.
*/
- if (type->is_void() && (this->identifier == NULL))
+ if (type->is_void()) {
+ if (this->identifier != NULL)
+ _mesa_glsl_error(& loc, state,
+ "named parameter cannot have type `void'");
+
+ is_void = true;
return NULL;
+ }
if (formal_parameter && (this->identifier == NULL)) {
_mesa_glsl_error(& loc, state, "formal parameter lacks a name");
return NULL;
}
+ is_void = false;
ir_variable *var = new ir_variable(type, this->identifier);
/* FINISHME: Handle array declarations. Note that this requires
@@ -1661,11 +1668,25 @@ ast_parameter_declarator::parameters_to_hir(struct simple_node *ast_parameters,
_mesa_glsl_parse_state *state)
{
struct simple_node *ptr;
+ ast_parameter_declarator *void_param = NULL;
+ unsigned count = 0;
foreach (ptr, ast_parameters) {
ast_parameter_declarator *param = (ast_parameter_declarator *)ptr;
param->formal_parameter = formal;
param->hir(ir_parameters, state);
+
+ if (param->is_void)
+ void_param = param;
+
+ count++;
+ }
+
+ if ((void_param != NULL) && (count > 1)) {
+ YYLTYPE loc = void_param->get_location();
+
+ _mesa_glsl_error(& loc, state,
+ "`void' parameter must be only parameter");
}
}