summaryrefslogtreecommitdiff
path: root/ast_to_hir.cpp
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-04-20 16:48:24 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-04-28 18:22:54 -0700
commit1d28b617ba66cfcb1641c9f516146d51aa82b118 (patch)
treea980a0fd80c3db911e174679bb7bcd7d631dcfbe /ast_to_hir.cpp
parent6efaeeea4489941f4916fda3041c2bf4e22b482e (diff)
Ensure that anonymous structures have non-NULL names
Diffstat (limited to 'ast_to_hir.cpp')
-rw-r--r--ast_to_hir.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp
index 2f83dd6597..a29a49d98d 100644
--- a/ast_to_hir.cpp
+++ b/ast_to_hir.cpp
@@ -2328,9 +2328,22 @@ ast_struct_specifier::hir(exec_list *instructions,
assert(i == decl_count);
- glsl_type *t = new glsl_type(fields, decl_count, this->name);
+ const char *name;
+ if (this->name == NULL) {
+ static unsigned anon_count = 1;
+ char buf[32];
- state->symbols->add_type(this->name, t);
+ snprintf(buf, sizeof(buf), "#anon_struct_%04x", anon_count);
+ anon_count++;
+
+ name = strdup(buf);
+ } else {
+ name = this->name;
+ }
+
+ glsl_type *t = new glsl_type(fields, decl_count, name);
+
+ state->symbols->add_type(name, t);
/* Structure type definitions do not have r-values.
*/