summaryrefslogtreecommitdiffstats
path: root/src/glsl
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2011-10-25 17:49:07 -0700
committerIan Romanick <ian.d.romanick@intel.com>2011-10-28 13:28:55 -0700
commitf5ba4d055ee27bfd741ad019e3b3d4b1a1ce9bd9 (patch)
tree5fd5a9817d772c4bdabafb774cef9b1b15efa8d3 /src/glsl
parenta04211ecb8c907eaef69832abc2e16cd6f9887a0 (diff)
glsl: Clean-up spurious error message on bad structure definitions
Previously a shader like int X; struct X { int i; }; void main() { gl_Position = vec4(0.0); } would generate two error message: 0:2(19): error: struct `X' previously defined 0:2(20): error: incomplete declaration The first one is the real error, and the second is spurious. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'src/glsl')
-rw-r--r--src/glsl/ast_to_hir.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index a60711d8055..7584fdf8c67 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2455,14 +2455,32 @@ ast_declarator_list::hir(exec_list *instructions,
decl_type = this->type->specifier->glsl_type(& type_name, state);
if (this->declarations.is_empty()) {
- if (decl_type != NULL) {
- /* Warn if this empty declaration is not for declaring a structure.
- */
- if (this->type->specifier->structure == NULL) {
+ /* If there is no structure involved in the program text, there are two
+ * possible scenarios:
+ *
+ * - The program text contained something like 'vec4;'. This is an
+ * empty declaration. It is valid but weird. Emit a warning.
+ *
+ * - The program text contained something like 'S;' and 'S' is not the
+ * name of a known structure type. This is both invalid and weird.
+ * Emit an error.
+ *
+ * Note that if decl_type is NULL and there is a structure involved,
+ * there must have been some sort of error with the structure. In this
+ * case we assume that an error was already generated on this line of
+ * code for the structure. There is no need to generate an additional,
+ * confusing error.
+ */
+ assert(this->type->specifier->structure == NULL || decl_type != NULL
+ || state->error);
+ if (this->type->specifier->structure == NULL) {
+ if (decl_type != NULL) {
_mesa_glsl_warning(&loc, state, "empty declaration");
+ } else {
+ _mesa_glsl_error(&loc, state,
+ "invalid type `%s' in empty declaration",
+ type_name);
}
- } else {
- _mesa_glsl_error(& loc, state, "incomplete declaration");
}
}