From: Eli Friedman Date: Wed, 14 Sep 2011 19:20:00 +0000 (+0000) Subject: PR10864: make sure we correctly delay type-checking for inline asm tied operands... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f45b357c0d0df99e160a6320e279ef788dd91ba6;p=clang PR10864: make sure we correctly delay type-checking for inline asm tied operands with dependent type. Patch by Likai Liu. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139716 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 7f175b3e1e..274c74c7b6 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -2121,6 +2121,10 @@ StmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc, bool IsSimple, unsigned InputOpNo = i+NumOutputs; Expr *OutputExpr = Exprs[TiedTo]; Expr *InputExpr = Exprs[InputOpNo]; + + if (OutputExpr->isTypeDependent() || InputExpr->isTypeDependent()) + continue; + QualType InTy = InputExpr->getType(); QualType OutTy = OutputExpr->getType(); if (Context.hasSameType(InTy, OutTy)) diff --git a/test/SemaTemplate/instantiate-expr-1.cpp b/test/SemaTemplate/instantiate-expr-1.cpp index 7af59fd2d1..896437488d 100644 --- a/test/SemaTemplate/instantiate-expr-1.cpp +++ b/test/SemaTemplate/instantiate-expr-1.cpp @@ -170,3 +170,16 @@ namespace PR6424 { template void Y2<3>::f(); } + +namespace PR10864 { + template class Vals {}; + template<> class Vals { public: static const int i = 1; }; + template<> class Vals { public: static const double i; }; + template void test_asm_tied(T o) { + __asm("addl $1, %0" : "=r" (o) : "0"(Vals::i)); // expected-error {{input with type 'double' matching output with type 'float'}} + } + void test_asm_tied() { + test_asm_tied(1); + test_asm_tied(1.f); // expected-note {{instantiation of}} + } +}