[MC/ELF] Accept zero for .align directive
[oota-llvm.git] / lib / MC / MCParser / AsmParser.cpp
index 5e174de8a9335cdf9a4ac36a15cbd5fa07233c9e..7126a909b9efa0666f4a7ad12cfb81d54354131e 100644 (file)
@@ -2706,7 +2706,11 @@ bool AsmParser::parseDirectiveAlign(bool IsPow2, unsigned ValueSize) {
 
     Alignment = 1ULL << Alignment;
   } else {
-    // Reject alignments that aren't a power of two, for gas compatibility.
+    // Reject alignments that aren't either a power of two or zero,
+    // for gas compatibility. Alignment of zero is silently rounded
+    // up to one.
+    if (Alignment == 0)
+      Alignment = 1;
     if (!isPowerOf2_64(Alignment))
       Error(AlignmentLoc, "alignment must be a power of 2");
   }