aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
-rw-r--r--sparse-llvm.c9
-rw-r--r--validation/backend/struct.c6
2 files changed, 9 insertions, 6 deletions
diff --git a/sparse-llvm.c b/sparse-llvm.c
index c32ff7d7..e385d27c 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -102,13 +102,10 @@ static LLVMTypeRef sym_struct_type(LLVMModuleRef module, struct symbol *sym)
LLVMTypeRef ret;
unsigned nr = 0;
- sprintf(buffer, "%.*s", sym->ident->len, sym->ident->name);
-
- ret = LLVMGetTypeByName(module, buffer);
- if (ret)
- return ret;
-
+ snprintf(buffer, sizeof(buffer), "struct.%s", sym->ident ? sym->ident->name : "anno");
ret = LLVMStructCreateNamed(LLVMGetGlobalContext(), buffer);
+ /* set ->aux to avoid recursion */
+ sym->aux = ret;
FOR_EACH_PTR(sym->symbol_list, member) {
LLVMTypeRef member_type;
diff --git a/validation/backend/struct.c b/validation/backend/struct.c
index 1afaf2db..905339af 100644
--- a/validation/backend/struct.c
+++ b/validation/backend/struct.c
@@ -9,10 +9,16 @@ struct symbol {
struct symbol *next_id;
};
+struct unnamed {
+ struct { int x, y; };
+};
+
static struct symbol sym;
static struct symbol *sym_p;
static struct symbol *sym_q = &sym;
+static struct unnamed un;
+
/*
* check-name: Struct code generation
* check-command: ./sparsec -c $file -o tmp.o