Skip to content

Commit 6b72a67

Browse files
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 llvm-svn: 237048
1 parent e76e7e9 commit 6b72a67

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

clang/lib/Parse/Parser.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,11 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs,
669669

670670
SourceLocation StartLoc = Tok.getLocation();
671671
SourceLocation EndLoc;
672+
673+
// Check if GNU-style InlineAsm is disabled.
674+
if (!getLangOpts().GNUAsm)
675+
Diag(StartLoc, diag::err_gnu_inline_asm_disabled);
676+
672677
ExprResult Result(ParseSimpleAsm(&EndLoc));
673678

674679
ExpectAndConsume(tok::semi, diag::err_expected_after,
@@ -1253,10 +1258,6 @@ ExprResult Parser::ParseSimpleAsm(SourceLocation *EndLoc) {
12531258
assert(Tok.is(tok::kw_asm) && "Not an asm!");
12541259
SourceLocation Loc = ConsumeToken();
12551260

1256-
// Check if GNU-style InlineAsm is disabled.
1257-
if (!getLangOpts().GNUAsm)
1258-
Diag(Loc, diag::err_gnu_inline_asm_disabled);
1259-
12601261
if (Tok.is(tok::kw_volatile)) {
12611262
// Remove from the end of 'asm' to the end of 'volatile'.
12621263
SourceRange RemovalRange(PP.getLocForEndOfToken(Loc),

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// RUN: %clang_cc1 %s -triple i686-apple-darwin -verify -fsyntax-only -fno-gnu-inline-asm
22

33
asm ("INST r1, 0"); // expected-error {{GNU-style inline assembly is disabled}}
4+
5+
void foo() __asm("__foo_func"); // AsmLabel is OK
6+
int foo1 asm("bar1") = 0; // OK
7+
48
void f (void) {
59
long long foo = 0, bar;
610
asm volatile("INST %0, %1" : "=r"(foo) : "r"(bar)); // expected-error {{GNU-style inline assembly is disabled}}

0 commit comments

Comments
 (0)