aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
-rw-r--r--sparse-llvm.c12
-rw-r--r--validation/backend/void-return-type.c13
2 files changed, 23 insertions, 2 deletions
diff --git a/sparse-llvm.c b/sparse-llvm.c
index e02e212f..213d42d3 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -150,7 +150,13 @@ static LLVMTypeRef sym_union_type(LLVMModuleRef module, struct symbol *sym)
static LLVMTypeRef sym_ptr_type(LLVMModuleRef module, struct symbol *sym)
{
- LLVMTypeRef type = symbol_type(module, sym->ctype.base_type);
+ LLVMTypeRef type;
+
+ /* 'void *' is treated like 'char *' */
+ if (is_void_type(sym->ctype.base_type))
+ type = LLVMInt8Type();
+ else
+ type = symbol_type(module, sym->ctype.base_type);
return LLVMPointerType(type, 0);
}
@@ -176,10 +182,12 @@ static LLVMTypeRef sym_basetype_type(struct symbol *sym)
}
} else {
switch (sym->bit_size) {
+ case -1:
+ ret = LLVMVoidType();
+ break;
case 1:
ret = LLVMInt1Type();
break;
- case -1: /* 'void *' is treated like 'char *' */
case 8:
ret = LLVMInt8Type();
break;
diff --git a/validation/backend/void-return-type.c b/validation/backend/void-return-type.c
new file mode 100644
index 00000000..b282fdee
--- /dev/null
+++ b/validation/backend/void-return-type.c
@@ -0,0 +1,13 @@
+static void foo(void)
+{
+}
+
+static void *bar(void *p)
+{
+ return p;
+}
+
+/*
+ * check-name: void return type code generation
+ * check-command: ./sparsec -c $file -o tmp.o
+ */