r219322 - ms-inline-asm: Correctly mark MS inline ASM labels as used

Ehsan Akhgari ehsan.akhgari at gmail.com
Wed Oct 8 10:28:35 PDT 2014


Author: ehsan
Date: Wed Oct  8 12:28:34 2014
New Revision: 219322

URL: http://llvm.org/viewvc/llvm-project?rev=219322&view=rev
Log:
ms-inline-asm: Correctly mark MS inline ASM labels as used

Summary: This fixes PR21155.

Test Plan: The patch includes a test.

Reviewers: rnk

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D5619

Modified:
    cfe/trunk/lib/Sema/SemaStmtAsm.cpp
    cfe/trunk/test/Sema/ms-inline-asm.c

Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=219322&r1=219321&r2=219322&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Wed Oct  8 12:28:34 2014
@@ -561,7 +561,10 @@ LabelDecl *Sema::GetOrCreateMSAsmLabel(S
   LabelDecl* Label = LookupOrCreateLabel(PP.getIdentifierInfo(ExternalLabelName),
                                          Location);
 
-  if (!Label->isMSAsmLabel()) {
+  if (Label->isMSAsmLabel()) {
+    // If we have previously created this label implicitly, mark it as used.
+    Label->markUsed(Context);
+  } else {
     // Otherwise, insert it, but only resolve it if we have seen the label itself.
     std::string InternalName;
     llvm::raw_string_ostream OS(InternalName);

Modified: cfe/trunk/test/Sema/ms-inline-asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/ms-inline-asm.c?rev=219322&r1=219321&r2=219322&view=diff
==============================================================================
--- cfe/trunk/test/Sema/ms-inline-asm.c (original)
+++ cfe/trunk/test/Sema/ms-inline-asm.c Wed Oct  8 12:28:34 2014
@@ -1,5 +1,5 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fasm-blocks -Wno-microsoft -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fasm-blocks -Wno-microsoft -Wunused-label -verify -fsyntax-only
 
 void t1(void) { 
  __asm __asm // expected-error {{__asm used with no assembly instructions}}
@@ -146,5 +146,11 @@ void t10() {
 
 void t11() {
 foo:
-  __asm mov eax, foo // expected-error {{use of undeclared label 'foo'}}
+  __asm mov eax, foo // expected-error {{use of undeclared label 'foo'}} expected-warning {{unused label 'foo'}}
+}
+
+void t12() {
+  __asm foo:
+  __asm bar: // expected-warning {{unused label 'bar'}}
+  __asm jmp foo
 }





More information about the cfe-commits mailing list