Hi Reid

I did more digging in the darwin system headers and realize there are lots more 
than AsmLabel that prevents the user using this flag correctly.
For example, we have quite many empty file scope assembly blocks asm(“”) which 
are used to disable tail call optimization.
I think it will be better if we should just ignore system headers rather than 
special case them. Patch attached.

Steven

diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp
index ed27a9e..9c5d85d 100644

- a/lib/Parse/Parser.cpp

+++ b/lib/Parse/Parser.cpp
@@ -671,7 +671,8 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange 
&attrs,

  SourceLocation EndLoc;
   
  // Check if GNU-style InlineAsm is disabled.

- if (!getLangOpts().GNUAsm)

+    if (!(getLangOpts().GNUAsm ||
+          PP.getSourceManager().isInSystemHeader(StartLoc)))

    Diag(StartLoc, diag::err_gnu_inline_asm_disabled);
   
  ExprResult Result(ParseSimpleAsm(&EndLoc));

diff --git a/test/Parser/no-gnu-inline-asm.c b/test/Parser/no-gnu-inline-asm.c
index 7089fa4..bae28de 100644

- a/test/Parser/no-gnu-inline-asm.c

+++ b/test/Parser/no-gnu-inline-asm.c
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 %s -triple i686-apple-darwin -verify -fsyntax-only 
-fno-gnu-inline-asm

+#include "no-gnu-inline-asm.h" // file scope asm is ok in system header
+
 asm ("INST r1, 0"); // expected-error {{GNU-style inline assembly is disabled}}

void foo() __asm("__foo_func"); // AsmLabel is OK
diff --git a/test/Parser/no-gnu-inline-asm.h b/test/Parser/no-gnu-inline-asm.h
new file mode 100644
index 0000000..ba12e08

- /dev/null

+++ b/test/Parser/no-gnu-inline-asm.h
@@ -0,0 +1,3 @@
+// Test -fno-gnu-inline-asm in system header
+#pragma clang system_header
+asm(""); // file scope asm is OK in system header


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D9679

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/



_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to