]> granicus.if.org Git - clang/commitdiff
[ms-inline asm] Don't diagnose an empty lookup for inline assmebly. This happen
authorChad Rosier <mcrosier@apple.com>
Fri, 24 May 2013 18:32:55 +0000 (18:32 +0000)
committerChad Rosier <mcrosier@apple.com>
Fri, 24 May 2013 18:32:55 +0000 (18:32 +0000)
for labels in inline assembly that aren't in the lookup tables.  E.g.,

  __asm {
   a:
   jmp a
  }

rdar://13983623

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182659 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Sema/Sema.h
lib/Sema/SemaExpr.cpp
lib/Sema/SemaStmtAsm.cpp
test/CodeGen/ms-inline-asm.cpp

index f4e5cd468b3728a5a722e2020bc2ee0fa185d0c7..3b4c213e94388aefde98438b8ac324cf94ffd14f 100644 (file)
@@ -3095,7 +3095,8 @@ public:
                                SourceLocation TemplateKWLoc,
                                UnqualifiedId &Id,
                                bool HasTrailingLParen, bool IsAddressOfOperand,
-                               CorrectionCandidateCallback *CCC = 0);
+                               CorrectionCandidateCallback *CCC = 0,
+                               bool IsInlineAsmIdentifier = false);
 
   void DecomposeUnqualifiedId(const UnqualifiedId &Id,
                               TemplateArgumentListInfo &Buffer,
index 9d6601af328b25f6c1288641b77c5197a217be08..a70e3917214a331311025b26daf3b4b786610352 100644 (file)
@@ -1821,7 +1821,8 @@ ExprResult Sema::ActOnIdExpression(Scope *S,
                                    UnqualifiedId &Id,
                                    bool HasTrailingLParen,
                                    bool IsAddressOfOperand,
-                                   CorrectionCandidateCallback *CCC) {
+                                   CorrectionCandidateCallback *CCC,
+                                   bool IsInlineAsmIdentifier) {
   assert(!(IsAddressOfOperand && HasTrailingLParen) &&
          "cannot be direct & operand and have a trailing lparen");
 
@@ -1937,6 +1938,10 @@ ExprResult Sema::ActOnIdExpression(Scope *S,
                                             IsAddressOfOperand, TemplateArgs);
       }
 
+      // Don't diagnose an empty lookup for inline assmebly.
+      if (IsInlineAsmIdentifier)
+        return ExprError();
+
       CorrectionCandidateCallback DefaultValidator;
       if (DiagnoseEmptyLookup(S, SS, R, CCC ? *CCC : DefaultValidator))
         return ExprError();
index 1b87476219472152db2e8833c1e93f103a274ca9..9169032178fe3f05a764f484f34c6d9b89071bd3 100644 (file)
@@ -381,7 +381,9 @@ ExprResult Sema::LookupInlineAsmIdentifier(CXXScopeSpec &SS,
 
   ExprResult Result = ActOnIdExpression(getCurScope(), SS, TemplateKWLoc, Id,
                                         /*trailing lparen*/ false,
-                                        /*is & operand*/ false);
+                                        /*is & operand*/ false,
+                                        /*CorrectionCandidateCallback=*/0,
+                                        /*IsInlineAsmIdentifier=*/ true);
 
   if (IsUnevaluatedContext)
     PopExpressionEvaluationContext();
index 8f824f9947b62850d561ba3f5b7f2b7d66ec6281..8b9109d0194bf193388052f9e8acdd77682d5673 100644 (file)
@@ -103,3 +103,11 @@ void test5() {
   __asm mov x, eax
   // CHECK: call void asm sideeffect inteldialect "mov dword ptr $0, eax", "=*m,~{dirflag},~{fpsr},~{flags}"(i32* [[X]])
 }
+
+// Just verify this doesn't emit an error.
+void test6() {
+  __asm {
+   a:
+   jmp a
+  }
+}