r182659 - [ms-inline asm] Don't diagnose an empty lookup for inline assmebly. This happen

Chad Rosier mcrosier at apple.com
Fri May 24 11:32:55 PDT 2013


Author: mcrosier
Date: Fri May 24 13:32:55 2013
New Revision: 182659

URL: http://llvm.org/viewvc/llvm-project?rev=182659&view=rev
Log:
[ms-inline asm] Don't diagnose an empty lookup for inline assmebly.  This happen
for labels in inline assembly that aren't in the lookup tables.  E.g.,

  __asm {
   a:
   jmp a
  }

rdar://13983623

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

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=182659&r1=182658&r2=182659&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri May 24 13:32:55 2013
@@ -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,

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=182659&r1=182658&r2=182659&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri May 24 13:32:55 2013
@@ -1821,7 +1821,8 @@ ExprResult Sema::ActOnIdExpression(Scope
                                    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
                                             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();

Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=182659&r1=182658&r2=182659&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Fri May 24 13:32:55 2013
@@ -381,7 +381,9 @@ ExprResult Sema::LookupInlineAsmIdentifi
 
   ExprResult Result = ActOnIdExpression(getCurScope(), SS, TemplateKWLoc, Id,
                                         /*trailing lparen*/ false,
-                                        /*is & operand*/ false);
+                                        /*is & operand*/ false,
+                                        /*CorrectionCandidateCallback=*/0,
+                                        /*IsInlineAsmIdentifier=*/ true);
 
   if (IsUnevaluatedContext)
     PopExpressionEvaluationContext();

Modified: cfe/trunk/test/CodeGen/ms-inline-asm.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.cpp?rev=182659&r1=182658&r2=182659&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/ms-inline-asm.cpp (original)
+++ cfe/trunk/test/CodeGen/ms-inline-asm.cpp Fri May 24 13:32:55 2013
@@ -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
+  }
+}





More information about the cfe-commits mailing list