r333589 - PR34520: after instantiating a non-templated member deduction guide, don't forget to push it into the class scope.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Wed May 30 13:24:10 PDT 2018


Author: rsmith
Date: Wed May 30 13:24:10 2018
New Revision: 333589

URL: http://llvm.org/viewvc/llvm-project?rev=333589&view=rev
Log:
PR34520: after instantiating a non-templated member deduction guide, don't forget to push it into the class scope.

Modified:
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
    cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=333589&r1=333588&r2=333589&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Wed May 30 13:24:10 2018
@@ -2833,7 +2833,10 @@ Decl *TemplateDeclInstantiator::VisitFun
 
 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) {

Modified: cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp?rev=333589&r1=333588&r2=333589&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp Wed May 30 13:24:10 2018
@@ -320,6 +320,18 @@ namespace injected_class_name {
   using T = decltype(b);
 }
 
+namespace member_guides {
+  // PR34520
+  template<class>
+  struct Foo {
+    template <class T> struct Bar {
+      Bar(...) {}
+    };
+    Bar(int) -> Bar<int>;
+  };
+  Foo<int>::Bar b = 0;
+}
+
 #else
 
 // expected-no-diagnostics




More information about the cfe-commits mailing list