r295379 - Properly set up the DeclContext for parameters of implicit deduction guides;
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 16 13:29:22 PST 2017
Author: rsmith
Date: Thu Feb 16 15:29:21 2017
New Revision: 295379
URL: http://llvm.org/viewvc/llvm-project?rev=295379&view=rev
Log:
Properly set up the DeclContext for parameters of implicit deduction guides;
this is needed for deferred instantiation of default arguments.
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=295379&r1=295378&r2=295379&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Feb 16 15:29:21 2017
@@ -1677,6 +1677,9 @@ private:
bool Explicit, TypeSourceInfo *TInfo,
SourceLocation LocStart, SourceLocation Loc,
SourceLocation LocEnd) {
+ ArrayRef<ParmVarDecl *> Params =
+ TInfo->getTypeLoc().castAs<FunctionProtoTypeLoc>().getParams();
+
// Build the implicit deduction guide template.
auto *Guide = FunctionDecl::Create(SemaRef.Context, DC, LocStart, Loc,
DeductionGuideName, TInfo->getType(),
@@ -1685,8 +1688,10 @@ private:
if (Explicit)
Guide->setExplicitSpecified();
Guide->setRangeEnd(LocEnd);
- Guide->setParams(
- TInfo->getTypeLoc().castAs<FunctionProtoTypeLoc>().getParams());
+ Guide->setParams(Params);
+
+ for (auto *Param : Params)
+ Param->setDeclContext(Guide);
auto *GuideTemplate = FunctionTemplateDecl::Create(
SemaRef.Context, DC, Loc, DeductionGuideName, TemplateParams, Guide);
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=295379&r1=295378&r2=295379&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp Thu Feb 16 15:29:21 2017
@@ -168,3 +168,11 @@ namespace nondeducible {
typename ...B>
X(float) -> X<A, B...>; // ok
}
+
+namespace default_args_from_ctor {
+ template <class A> struct S { S(A = 0) {} };
+ S s(0);
+
+ template <class A> struct T { template<typename B> T(A = 0, B = 0) {} };
+ T t(0, 0);
+}
More information about the cfe-commits
mailing list