<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Thanks Reid! Actually, for the consistency, I should allow empty function scope as well. Dup the same logic in the StmtAsm parser. Committed in r237073.</div><div class=""><br class=""></div><div class="">Steven</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 11, 2015, at 5:11 PM, Reid Kleckner <<a href="mailto:rnk@google.com" class="">rnk@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">Sounds good, go for it.</div><div class="gmail_quote"><br class=""></div><div class="gmail_quote">On Mon, May 11, 2015 at 4:53 PM, Steven Wu <span dir="ltr" class=""><<a href="mailto:stevenwu@apple.com" target="_blank" class="">stevenwu@apple.com</a>></span> wrote:<br class=""></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 class="">
<br class="">
commit 9dd3fdfa3a90687e46c4731c9d23f4f1885a23f9<br class="">
Author: Steven Wu <<a href="mailto:stevenwu@apple.com" class="">stevenwu@apple.com</a>><br class="">
Date:   Mon May 11 16:47:27 2015 -0700<br class="">
<br class="">
    Allow empty assembly string literal with -fno-gnu-inline-asm<br class="">
<br class="">
    Empty assembly string will not introduce assembly code in the output<br class="">
    binary and it is often used as a trick in the header to disable<br class="">
    optimizations. It doesn't conflict with the purpose of the option so it<br class="">
    is allowed with -fno-gnu-inline-asm flag.<br class="">
<br class="">
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp<br class="">
index ed27a9e..697fda9 100644<br class="">
--- a/lib/Parse/Parser.cpp<br class="">
+++ b/lib/Parse/Parser.cpp<br class="">
@@ -670,12 +670,17 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs,<br class="">
<span class="">     SourceLocation StartLoc = Tok.getLocation();<br class="">
     SourceLocation EndLoc;<br class="">
<br class="">
</span><span class="">-    // Check if GNU-style InlineAsm is disabled.<br class="">
-    if (!getLangOpts().GNUAsm)<br class="">
</span>-      Diag(StartLoc, diag::err_gnu_inline_asm_disabled);<br class="">
-<br class="">
     ExprResult Result(ParseSimpleAsm(&EndLoc));<br class="">
<span class=""><br class="">
+    // Check if GNU-style InlineAsm is disabled.<br class="">
</span>+    // Empty asm string is allowed because it will not introduce<br class="">
+    // any assembly code.<br class="">
+    if (!(getLangOpts().GNUAsm || Result.isInvalid())) {<br class="">
+      const auto *SL = cast<StringLiteral>(Result.get());<br class="">
+      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 class="">
+    }<br class="">
</span>+<br class="">
     ExpectAndConsume(tok::semi, diag::err_expected_after,<br class="">
                      "top-level asm block");<br class="">
<br class="">
diff --git a/test/Parser/no-gnu-inline-asm.c b/test/Parser/no-gnu-inline-asm.c<br class="">
index 7089fa4..7a13f20 100644<br class="">
--- a/test/Parser/no-gnu-inline-asm.c<br class="">
+++ b/test/Parser/no-gnu-inline-asm.c<br class="">
@@ -5,6 +5,8 @@ asm ("INST r1, 0"); // expected-error {{GNU-style inline assembly is disabled}}<br class="">
<span class=""> void foo() __asm("__foo_func"); // AsmLabel is OK<br class="">
</span><span class=""> int foo1 asm("bar1") = 0; // OK<br class="">
<br class="">
</span>+asm(" "); // Whitespace is OK<br class=""></blockquote><div class=""><br class=""></div><div class="">I think it's more interesting to test this in a function context instead of a module context.</div></div></div></div>
</div></blockquote></div><br class=""></div></body></html>