From: Douglas Gregor Date: Mon, 11 Jan 2010 18:53:25 +0000 (+0000) Subject: Add support for out-of-line definitions of conversion function X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0c55106cf91a8aaa82199eeae6db0c5f8696b791;p=clang Add support for out-of-line definitions of conversion function templates. Previously, a little thinko in the code that replaced a conversion function template with its redeclaration was causing some very weird lookup behavior. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93166 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 41f0886e76..fd2abf88cd 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -2746,11 +2746,14 @@ Sema::DeclPtrTy Sema::ActOnConversionDeclarator(CXXConversionDecl *Conversion) { if (Conversion->getPrimaryTemplate()) { // ignore specializations } else if (Conversion->getPreviousDeclaration()) { - const NamedDecl *ExpectedPrevDecl = Conversion->getPreviousDeclaration(); if (FunctionTemplateDecl *ConversionTemplate - = Conversion->getDescribedFunctionTemplate()) - ExpectedPrevDecl = ConversionTemplate->getPreviousDeclaration(); - if (ClassDecl->replaceConversion(ExpectedPrevDecl, Conversion)) + = Conversion->getDescribedFunctionTemplate()) { + if (ClassDecl->replaceConversion( + ConversionTemplate->getPreviousDeclaration(), + ConversionTemplate)) + return DeclPtrTy::make(ConversionTemplate); + } else if (ClassDecl->replaceConversion(Conversion->getPreviousDeclaration(), + Conversion)) return DeclPtrTy::make(Conversion); assert(Conversion->isInvalidDecl() && "Conversion should not get here."); } else if (FunctionTemplateDecl *ConversionTemplate