From: Steven Wu Date: Tue, 28 Apr 2015 21:49:09 +0000 (+0000) Subject: Fix -fno-gnu-inline-asm doesn't catch file scope asm X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6942f2a3e029037cecd1604c35c368724df738eb;p=clang Fix -fno-gnu-inline-asm doesn't catch file scope asm Summary: FileScopeAsm should be treated the same as funcion level inline asm. -fno-gnu-inline-asm should trigger an error if file scope asm is used. I missed this case from r226340. This should not affect ms-extension because it is not allowed in the file scope. Reviewers: bob.wilson, rnk Reviewed By: rnk Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D9328 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236044 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index 3b56102dcf..81adbfba8b 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -1253,6 +1253,10 @@ ExprResult Parser::ParseSimpleAsm(SourceLocation *EndLoc) { assert(Tok.is(tok::kw_asm) && "Not an asm!"); SourceLocation Loc = ConsumeToken(); + // Check if GNU-styple 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 78f470fa66..d73d6123a0 100644 --- a/test/Parser/no-gnu-inline-asm.c +++ b/test/Parser/no-gnu-inline-asm.c @@ -1,5 +1,6 @@ // 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 f (void) { long long foo = 0, bar; asm volatile("INST %0, %1" : "=r"(foo) : "r"(bar)); // expected-error {{GNU-style inline assembly is disabled}}