[PATCH] D36060: [AsmParser][GAS-compatibility] Ignore an empty 'p2align' directive

coby via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 2 10:36:59 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL309841: [AsmParser][GAS-compatibility] Ignore an empty 'p2align' directive (authored by coby).

Changed prior to commit:
  https://reviews.llvm.org/D36060?vs=108831&id=109376#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36060

Files:
  llvm/trunk/lib/MC/MCParser/AsmParser.cpp
  llvm/trunk/test/MC/AsmParser/directive_align.s


Index: llvm/trunk/test/MC/AsmParser/directive_align.s
===================================================================
--- llvm/trunk/test/MC/AsmParser/directive_align.s
+++ llvm/trunk/test/MC/AsmParser/directive_align.s
@@ -1,4 +1,5 @@
-# RUN: not llvm-mc -triple i386-apple-darwin9 %s | FileCheck %s
+# RUN: not llvm-mc -triple i386-apple-darwin9 %s 2> %t.err | FileCheck %s
+# RUN: FileCheck < %t.err %s --check-prefix=CHECK-WARN
 
 # CHECK: TEST0:
 # CHECK: .p2align 1
@@ -14,3 +15,7 @@
 # CHECK: .balign 3, 10
 TEST2:  
         .balign 3,10
+
+# CHECK-WARN: p2align directive with no operand(s) is ignored
+TEST3:  
+        .p2align
Index: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
===================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp
@@ -3199,7 +3199,7 @@
   int64_t MaxBytesToFill = 0;
 
   auto parseAlign = [&]() -> bool {
-    if (checkForValidSection() || parseAbsoluteExpression(Alignment))
+    if (parseAbsoluteExpression(Alignment))
       return true;
     if (parseOptionalToken(AsmToken::Comma)) {
       // The fill expression can be omitted while specifying a maximum number of
@@ -3218,6 +3218,13 @@
     return parseToken(AsmToken::EndOfStatement);
   };
 
+  if (checkForValidSection())
+    return addErrorSuffix(" in directive");
+  // Ignore empty '.p2align' directives for GNU-as compatibility
+  if (IsPow2 && (ValueSize == 1) && getTok().is(AsmToken::EndOfStatement)) {
+    Warning(AlignmentLoc, "p2align directive with no operand(s) is ignored");
+    return parseToken(AsmToken::EndOfStatement);
+  }
   if (parseAlign())
     return addErrorSuffix(" in directive");
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36060.109376.patch
Type: text/x-patch
Size: 1710 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170802/45c0427b/attachment.bin>


More information about the llvm-commits mailing list