[llvm-commits] [llvm] r80077 - /llvm/trunk/tools/llvm-mc/AsmParser.cpp

Daniel Dunbar daniel at zuster.org
Wed Aug 26 02:16:35 PDT 2009


Author: ddunbar
Date: Wed Aug 26 04:16:34 2009
New Revision: 80077

URL: http://llvm.org/viewvc/llvm-project?rev=80077&view=rev
Log:
llvm-mc: Make non-sensical max bytes to .align an error.

Also, warn about overflow in alignment values.

Modified:
    llvm/trunk/tools/llvm-mc/AsmParser.cpp

Modified: llvm/trunk/tools/llvm-mc/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.cpp?rev=80077&r1=80076&r2=80077&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmParser.cpp (original)
+++ llvm/trunk/tools/llvm-mc/AsmParser.cpp Wed Aug 26 04:16:34 2009
@@ -1024,6 +1024,7 @@
 /// ParseDirectiveAlign
 ///  ::= {.align, ...} expression [ , expression [ , expression ]]
 bool AsmParser::ParseDirectiveAlign(bool IsPow2, unsigned ValueSize) {
+  SMLoc AlignmentLoc = Lexer.getLoc();
   int64_t Alignment;
   if (ParseAbsoluteExpression(Alignment))
     return true;
@@ -1070,15 +1071,19 @@
   // Compute alignment in bytes.
   if (IsPow2) {
     // FIXME: Diagnose overflow.
-    Alignment = 1LL << Alignment;
+    if (Alignment >= 32) {
+      Error(AlignmentLoc, "invalid alignment value");
+      Alignment = 31;
+    }
+
+    Alignment = 1 << Alignment;
   }
 
-  // Diagnose non-sensical max bytes to fill, which are treated as missing (this
-  // matches 'as').
+  // Diagnose non-sensical max bytes to align.
   if (MaxBytesLoc.isValid()) {
     if (MaxBytesToFill < 1) {
-      Warning(MaxBytesLoc, "alignment directive can never be satisfied in this "
-              "many bytes, ignoring maximum bytes expression");
+      Error(MaxBytesLoc, "alignment directive can never be satisfied in this "
+            "many bytes, ignoring maximum bytes expression");
       MaxBytesToFill = 0;
     }
 





More information about the llvm-commits mailing list