From 92af77f45cf673394a7c73f64a58cd6a463ec15f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 5 Jan 2009 07:46:05 +0000 Subject: [PATCH] PR3281:crash00.ll: produce this diagnostic instead of crashing: @t = global i8 0, align 3 ^ llvm-svn: 61675 --- lib/AsmParser/LLParser.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index e44e65057ca..1f08ca34ff1 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -793,7 +793,11 @@ bool LLParser::ParseOptionalAlignment(unsigned &Alignment) { Alignment = 0; if (!EatIfPresent(lltok::kw_align)) return false; - return ParseUInt32(Alignment); + LocTy AlignLoc = Lex.getLoc(); + if (ParseUInt32(Alignment)) return true; + if (!isPowerOf2_32(Alignment)) + return Error(AlignLoc, "alignment is not a power of two"); + return false; } /// ParseOptionalCommaAlignment