summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2010-03-31 09:56:36 -1000
committerIan Romanick <ian.d.romanick@intel.com>2010-04-02 11:05:16 -0700
commit068c80cfe0a280490353b6b007165d717c672eed (patch)
tree58e9d86f4ed90c23e71aab27fa7f45be44b965c6
parent03d3f3ab71ba280071f54cb60505212be6710f8e (diff)
Don't create a parameter declaration for a (void) parameter.
Fixes segfaults in a shader consisting of just: void main(void) { } Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
-rw-r--r--ast_to_hir.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp
index ca3c869dd8..137abdaaa6 100644
--- a/ast_to_hir.cpp
+++ b/ast_to_hir.cpp
@@ -1501,6 +1501,21 @@ ast_parameter_declarator::hir(exec_list *instructions,
type = glsl_type::error_type;
}
+ /* From page 62 (page 68 of the PDF) of the GLSL 1.50 spec:
+ *
+ * "Functions that accept no input arguments need not use void in the
+ * argument list because prototypes (or definitions) are required and
+ * therefore there is no ambiguity when an empty argument list "( )" is
+ * declared. The idiom "(void)" as a parameter list is provided for
+ * convenience."
+ *
+ * Placing this check here prevents a void parameter being set up
+ * 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))
+ return NULL;
+
ir_variable *var = new ir_variable(type, this->identifier);
/* FINISHME: Handle array declarations. Note that this requires
@@ -1530,7 +1545,9 @@ ast_function_parameters_to_hir(struct simple_node *ast_parameters,
struct simple_node *ptr;
foreach (ptr, ast_parameters) {
- ((ast_node *)ptr)->hir(ir_parameters, state);
+ ast_node *param = (ast_node *)ptr;
+ param->hir(ir_parameters, state);
+
}
}