From 942dfe2e4d75f9d7c6f2e73eadac6fa659a5f853 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Fri, 24 May 2013 18:32:55 +0000 Subject: [PATCH] [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182659 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Sema/Sema.h | 3 ++- lib/Sema/SemaExpr.cpp | 7 ++++++- lib/Sema/SemaStmtAsm.cpp | 4 +++- test/CodeGen/ms-inline-asm.cpp | 8 ++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index f4e5cd468b..3b4c213e94 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -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, diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 9d6601af32..a70e391721 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -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(); diff --git a/lib/Sema/SemaStmtAsm.cpp b/lib/Sema/SemaStmtAsm.cpp index 1b87476219..9169032178 100644 --- a/lib/Sema/SemaStmtAsm.cpp +++ b/lib/Sema/SemaStmtAsm.cpp @@ -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(); diff --git a/test/CodeGen/ms-inline-asm.cpp b/test/CodeGen/ms-inline-asm.cpp index 8f824f9947..8b9109d019 100644 --- a/test/CodeGen/ms-inline-asm.cpp +++ b/test/CodeGen/ms-inline-asm.cpp @@ -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 + } +} -- 2.40.0