r363361 - [clang] Fixing incorrect implicit deduction guides (PR41549)
Gauthier Harnisch via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 14 01:40:04 PDT 2019
Author: tyker
Date: Fri Jun 14 01:40:04 2019
New Revision: 363361
URL: http://llvm.org/viewvc/llvm-project?rev=363361&view=rev
Log:
[clang] Fixing incorrect implicit deduction guides (PR41549)
Summary:
[[ https://bugs.llvm.org/show_bug.cgi?id=41549 | bug report ]]
Before this patch, implicit deduction guides were generated from the first declaration found by lookup.
With this patch implicit deduction guides are generated from the definition of the class template.
Also added test that was previously failing.
Reviewers: rsmith
Reviewed By: rsmith
Subscribers: cfe-commits, Quuxplusone
Tags: #clang
Differential Revision: https://reviews.llvm.org/D63072
Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=363361&r1=363360&r2=363361&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Jun 14 01:40:04 2019
@@ -2052,6 +2052,12 @@ private:
void Sema::DeclareImplicitDeductionGuides(TemplateDecl *Template,
SourceLocation Loc) {
+ if (CXXRecordDecl *DefRecord =
+ cast<CXXRecordDecl>(Template->getTemplatedDecl())->getDefinition()) {
+ TemplateDecl *DescribedTemplate = DefRecord->getDescribedClassTemplate();
+ Template = DescribedTemplate ? DescribedTemplate : Template;
+ }
+
DeclContext *DC = Template->getDeclContext();
if (DC->isDependentContext())
return;
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=363361&r1=363360&r2=363361&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp Fri Jun 14 01:40:04 2019
@@ -489,6 +489,21 @@ static_assert(__is_same(decltype(ta), Te
}
#pragma clang diagnostic pop
+namespace PR41549 {
+
+template <class H, class P> struct umm;
+
+template <class H = int, class P = int>
+struct umm {
+ umm(H h = 0, P p = 0);
+};
+
+template <class H, class P> struct umm;
+
+umm m(1);
+
+}
+
#else
// expected-no-diagnostics
More information about the cfe-commits
mailing list