Fix crash with function declarations with unnamed parameters.

Fixes issue #103.
Previously, we were inadvertently grabbing the function's return type
  for the parameter, rather than the actual parameter type.
This commit is contained in:
Matt Pharr
2011-09-23 15:05:59 -07:00
parent 7126a39092
commit 5584240c7f
2 changed files with 2 additions and 1 deletions

View File

@@ -237,7 +237,7 @@ Declarator::GetType(DeclSpecs *ds) const {
sprintf(buf, "__anon_parameter_%d", i); sprintf(buf, "__anon_parameter_%d", i);
sym = new Symbol(buf, pos); sym = new Symbol(buf, pos);
Declarator *declarator = new Declarator(sym, sym->pos); Declarator *declarator = new Declarator(sym, sym->pos);
sym->type = declarator->GetType(ds); sym->type = declarator->GetType(d->declSpecs);
d->declarators.push_back(declarator); d->declarators.push_back(declarator);
} }
else { else {

View File

@@ -1833,6 +1833,7 @@ FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool includeMask) const {
for (unsigned int i = 0; i < argTypes.size(); ++i) { for (unsigned int i = 0; i < argTypes.size(); ++i) {
if (!argTypes[i]) if (!argTypes[i])
return NULL; return NULL;
assert(argTypes[i] != AtomicType::Void);
LLVM_TYPE_CONST llvm::Type *t = argTypes[i]->LLVMType(ctx); LLVM_TYPE_CONST llvm::Type *t = argTypes[i]->LLVMType(ctx);
if (!t) if (!t)