From: Steven Wu Date: Mon, 11 May 2015 21:14:09 +0000 (+0000) Subject: Allow AsmLabel with -fno-gnu-inline-asm X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=99689c203f111fe188903892b4f2e1ab7c86ddc9;p=clang Allow AsmLabel with -fno-gnu-inline-asm Summary: AsmLabel is heavily used in system level and firmware to redirect function and access platform specific labels. They are also extensively used in system headers which makes this option unusable for many users. Since AsmLabel doesn't introduce any assembly code into the output binary, it shouldn't be considered as inline-asm. Reviewers: bob.wilson, rnk Reviewed By: rnk Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D9679 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@237048 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index 6211322719..ed27a9e395 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -669,6 +669,11 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs, SourceLocation StartLoc = Tok.getLocation(); SourceLocation EndLoc; + + // Check if GNU-style InlineAsm is disabled. + if (!getLangOpts().GNUAsm) + Diag(StartLoc, diag::err_gnu_inline_asm_disabled); + ExprResult Result(ParseSimpleAsm(&EndLoc)); ExpectAndConsume(tok::semi, diag::err_expected_after, @@ -1253,10 +1258,6 @@ ExprResult Parser::ParseSimpleAsm(SourceLocation *EndLoc) { assert(Tok.is(tok::kw_asm) && "Not an asm!"); SourceLocation Loc = ConsumeToken(); - // Check if GNU-style InlineAsm is disabled. - if (!getLangOpts().GNUAsm) - Diag(Loc, diag::err_gnu_inline_asm_disabled); - if (Tok.is(tok::kw_volatile)) { // Remove from the end of 'asm' to the end of 'volatile'. SourceRange RemovalRange(PP.getLocForEndOfToken(Loc), diff --git a/test/Parser/no-gnu-inline-asm.c b/test/Parser/no-gnu-inline-asm.c index d73d6123a0..7089fa4b7d 100644 --- a/test/Parser/no-gnu-inline-asm.c +++ b/test/Parser/no-gnu-inline-asm.c @@ -1,6 +1,10 @@ // RUN: %clang_cc1 %s -triple i686-apple-darwin -verify -fsyntax-only -fno-gnu-inline-asm asm ("INST r1, 0"); // expected-error {{GNU-style inline assembly is disabled}} + +void foo() __asm("__foo_func"); // AsmLabel is OK +int foo1 asm("bar1") = 0; // OK + void f (void) { long long foo = 0, bar; asm volatile("INST %0, %1" : "=r"(foo) : "r"(bar)); // expected-error {{GNU-style inline assembly is disabled}}