<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Sounds good, go for it.</div><div class="gmail_quote"><br></div><div class="gmail_quote">On Mon, May 11, 2015 at 4:53 PM, Steven Wu <span dir="ltr"><<a href="mailto:stevenwu@apple.com" target="_blank">stevenwu@apple.com</a>></span> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Great! If the extra special case doesn’t make the option ambiguous about what it is doing, I am happier with this approach. Here is the patch.<br>
<br>
commit 9dd3fdfa3a90687e46c4731c9d23f4f1885a23f9<br>
Author: Steven Wu <<a href="mailto:stevenwu@apple.com">stevenwu@apple.com</a>><br>
Date:   Mon May 11 16:47:27 2015 -0700<br>
<br>
    Allow empty assembly string literal with -fno-gnu-inline-asm<br>
<br>
    Empty assembly string will not introduce assembly code in the output<br>
    binary and it is often used as a trick in the header to disable<br>
    optimizations. It doesn't conflict with the purpose of the option so it<br>
    is allowed with -fno-gnu-inline-asm flag.<br>
<br>
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp<br>
index ed27a9e..697fda9 100644<br>
--- a/lib/Parse/Parser.cpp<br>
+++ b/lib/Parse/Parser.cpp<br>
@@ -670,12 +670,17 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs,<br>
<span class="">     SourceLocation StartLoc = Tok.getLocation();<br>
     SourceLocation EndLoc;<br>
<br>
</span><span class="">-    // Check if GNU-style InlineAsm is disabled.<br>
-    if (!getLangOpts().GNUAsm)<br>
</span>-      Diag(StartLoc, diag::err_gnu_inline_asm_disabled);<br>
-<br>
     ExprResult Result(ParseSimpleAsm(&EndLoc));<br>
<span class=""><br>
+    // Check if GNU-style InlineAsm is disabled.<br>
</span>+    // Empty asm string is allowed because it will not introduce<br>
+    // any assembly code.<br>
+    if (!(getLangOpts().GNUAsm || Result.isInvalid())) {<br>
+      const auto *SL = cast<StringLiteral>(Result.get());<br>
+      if (!SL->getString().trim().empty())</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="">+        Diag(StartLoc, diag::err_gnu_inline_asm_disabled);<br>
+    }<br>
</span>+<br>
     ExpectAndConsume(tok::semi, diag::err_expected_after,<br>
                      "top-level asm block");<br>
<br>
diff --git a/test/Parser/no-gnu-inline-asm.c b/test/Parser/no-gnu-inline-asm.c<br>
index 7089fa4..7a13f20 100644<br>
--- a/test/Parser/no-gnu-inline-asm.c<br>
+++ b/test/Parser/no-gnu-inline-asm.c<br>
@@ -5,6 +5,8 @@ asm ("INST r1, 0"); // expected-error {{GNU-style inline assembly is disabled}}<br>
<span class=""> void foo() __asm("__foo_func"); // AsmLabel is OK<br>
</span><span class=""> int foo1 asm("bar1") = 0; // OK<br>
<br>
</span>+asm(" "); // Whitespace is OK<br></blockquote><div><br></div><div>I think it's more interesting to test this in a function context instead of a module context.</div></div></div></div>