PR3281:crash00.ll: produce this diagnostic instead of crashing:
authorChris Lattner <sabre@nondot.org>
Mon, 5 Jan 2009 07:46:05 +0000 (07:46 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 5 Jan 2009 07:46:05 +0000 (07:46 +0000)
@t = global i8 0, align 3
                        ^

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61675 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AsmParser/LLParser.cpp

index e44e65057ca3bbd3ab0079c2b61df5180958cf0f..1f08ca34ff1148df6e1ab4df9516222180f926a4 100644 (file)
@@ -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