]> granicus.if.org Git - clang/commitdiff
PR34520: after instantiating a non-templated member deduction guide, don't forget...
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 30 May 2018 20:24:10 +0000 (20:24 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 30 May 2018 20:24:10 +0000 (20:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333589 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplateInstantiateDecl.cpp
test/SemaCXX/cxx1z-class-template-argument-deduction.cpp

index cd80215d0447ff5e7dd9af2e0f84b49ccae218ce..dd62d4c98f39ab7654af9106ab1e41407b773040 100644 (file)
@@ -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) {
index d21fbf28928997f36540a1cba3ab0ddec1a81525..90f168d3fcc5ccb9d1408d8789865326b80c2578 100644 (file)
@@ -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