From: Richard Smith Date: Wed, 30 May 2018 20:24:10 +0000 (+0000) Subject: PR34520: after instantiating a non-templated member deduction guide, don't forget... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=83064f9c4767b1df85d023d9bc993c615d0ef3d5;p=clang PR34520: after instantiating a non-templated member deduction guide, don't forget to push it into the class scope. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333589 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index cd80215d04..dd62d4c98f 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -2833,7 +2833,10 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D) { Decl * TemplateDeclInstantiator::VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D) { - return VisitFunctionDecl(D, nullptr); + Decl *Inst = VisitFunctionDecl(D, nullptr); + if (Inst && !D->getDescribedFunctionTemplate()) + Owner->addDecl(Inst); + return Inst; } Decl *TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D) { diff --git a/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp b/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp index d21fbf2892..90f168d3fc 100644 --- a/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp +++ b/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp @@ -320,6 +320,18 @@ namespace injected_class_name { using T = decltype(b); } +namespace member_guides { + // PR34520 + template + struct Foo { + template struct Bar { + Bar(...) {} + }; + Bar(int) -> Bar; + }; + Foo::Bar b = 0; +} + #else // expected-no-diagnostics