diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/DeclCXX.cpp | 36 | ||||
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 37 |
2 files changed, 45 insertions, 28 deletions
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index 6e879ee9ee..19caae5b7f 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -493,6 +493,30 @@ void CXXRecordDecl::addedMember(Decl *D) { data().PlainOldData = false; } + // Keep the list of conversion functions up-to-date. + if (CXXConversionDecl *Conversion = dyn_cast<CXXConversionDecl>(D)) { + // We don't record specializations. + if (Conversion->getPrimaryTemplate()) + return; + + // FIXME: We intentionally don't use the decl's access here because it + // hasn't been set yet. That's really just a misdesign in Sema. + + if (FunTmpl) { + if (FunTmpl->getPreviousDeclaration()) + data().Conversions.replace(FunTmpl->getPreviousDeclaration(), + FunTmpl); + else + data().Conversions.addDecl(FunTmpl); + } else { + if (Conversion->getPreviousDeclaration()) + data().Conversions.replace(Conversion->getPreviousDeclaration(), + Conversion); + else + data().Conversions.addDecl(Conversion); + } + } + return; } @@ -546,6 +570,12 @@ void CXXRecordDecl::addedMember(Decl *D) { } } } + + // Handle using declarations of conversion functions. + if (UsingShadowDecl *Shadow = dyn_cast<UsingShadowDecl>(D)) + if (Shadow->getDeclName().getNameKind() + == DeclarationName::CXXConversionFunctionName) + data().Conversions.addDecl(Shadow, Shadow->getAccess()); } static CanQualType GetConversionType(ASTContext &Context, NamedDecl *Conv) { @@ -833,6 +863,12 @@ void CXXRecordDecl::completeDefinition(CXXFinalOverriderMap *FinalOverriders) { } } } + + // Set access bits correctly on the directly-declared conversions. + for (UnresolvedSetIterator I = data().Conversions.begin(), + E = data().Conversions.end(); + I != E; ++I) + data().Conversions.setAccess(I, (*I)->getAccess()); } bool CXXRecordDecl::mayBeAbstract() const { diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index e0049e636f..1e4065454e 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -3107,25 +3107,10 @@ Decl *Sema::ActOnConversionDeclarator(CXXConversionDecl *Conversion) { << ClassType << ConvType; } - if (Conversion->getPrimaryTemplate()) { - // ignore specializations - } else if (Conversion->getPreviousDeclaration()) { - if (FunctionTemplateDecl *ConversionTemplate - = Conversion->getDescribedFunctionTemplate()) { - if (ClassDecl->replaceConversion( - ConversionTemplate->getPreviousDeclaration(), - ConversionTemplate)) - return ConversionTemplate; - } else if (ClassDecl->replaceConversion(Conversion->getPreviousDeclaration(), - Conversion)) - return Conversion; - assert(Conversion->isInvalidDecl() && "Conversion should not get here."); - } else if (FunctionTemplateDecl *ConversionTemplate - = Conversion->getDescribedFunctionTemplate()) - ClassDecl->addConversionFunction(ConversionTemplate); - else - ClassDecl->addConversionFunction(Conversion); - + if (FunctionTemplateDecl *ConversionTemplate + = Conversion->getDescribedFunctionTemplate()) + return ConversionTemplate; + return Conversion; } @@ -3669,20 +3654,16 @@ UsingShadowDecl *Sema::BuildUsingShadowDecl(Scope *S, = UsingShadowDecl::Create(Context, CurContext, UD->getLocation(), UD, Target); UD->addShadowDecl(Shadow); - + + Shadow->setAccess(UD->getAccess()); + if (Orig->isInvalidDecl() || UD->isInvalidDecl()) + Shadow->setInvalidDecl(); + if (S) PushOnScopeChains(Shadow, S); else CurContext->addDecl(Shadow); - Shadow->setAccess(UD->getAccess()); - // Register it as a conversion if appropriate. - if (Shadow->getDeclName().getNameKind() - == DeclarationName::CXXConversionFunctionName) - cast<CXXRecordDecl>(CurContext)->addConversionFunction(Shadow); - - if (Orig->isInvalidDecl() || UD->isInvalidDecl()) - Shadow->setInvalidDecl(); return Shadow; } |