/// ::= 'alloca' 'inalloca'? Type (',' TypeAndValue)? (',' 'align' i32)?
int LLParser::ParseAlloc(Instruction *&Inst, PerFunctionState &PFS) {
Value *Size = nullptr;
- LocTy SizeLoc;
+ LocTy SizeLoc, TyLoc;
unsigned Alignment = 0;
Type *Ty = nullptr;
bool IsInAlloca = EatIfPresent(lltok::kw_inalloca);
- if (ParseType(Ty)) return true;
+ if (ParseType(Ty, TyLoc)) return true;
- if (!PointerType::isValidElementType(Ty))
- return TokError("pointer to this type is invalid");
+ if (Ty->isFunctionTy() || !PointerType::isValidElementType(Ty))
+ return Error(TyLoc, "invalid type for alloca");
bool AteExtraComma = false;
if (EatIfPresent(lltok::comma)) {