<div dir="ltr">Hi Richard,<div><br></div><div>One more issue. When compiling with `-g` the following code hits a `llvm_unreachable` in CGDebugInfo::CreateTypeNode.</div><div><br></div><div>template <class T> struct S { S(T) {} };</div><div>S s(42); </div><div><br></div><div>/Eric</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 16, 2017 at 2:29 PM, Richard Smith via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rsmith<br>
Date: Thu Feb 16 15:29:21 2017<br>
New Revision: 295379<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=295379&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=295379&view=rev</a><br>
Log:<br>
Properly set up the DeclContext for parameters of implicit deduction guides;<br>
this is needed for deferred instantiation of default arguments.<br>
<br>
Modified:<br>
cfe/trunk/lib/Sema/<wbr>SemaTemplate.cpp<br>
cfe/trunk/test/SemaCXX/cxx1z-<wbr>class-template-argument-<wbr>deduction.cpp<br>
<br>
Modified: cfe/trunk/lib/Sema/<wbr>SemaTemplate.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=295379&r1=295378&r2=295379&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Sema/<wbr>SemaTemplate.cpp?rev=295379&<wbr>r1=295378&r2=295379&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Sema/<wbr>SemaTemplate.cpp (original)<br>
+++ cfe/trunk/lib/Sema/<wbr>SemaTemplate.cpp Thu Feb 16 15:29:21 2017<br>
@@ -1677,6 +1677,9 @@ private:<br>
bool Explicit, TypeSourceInfo *TInfo,<br>
SourceLocation LocStart, SourceLocation Loc,<br>
SourceLocation LocEnd) {<br>
+ ArrayRef<ParmVarDecl *> Params =<br>
+ TInfo->getTypeLoc().castAs<<wbr>FunctionProtoTypeLoc>().<wbr>getParams();<br>
+<br>
// Build the implicit deduction guide template.<br>
auto *Guide = FunctionDecl::Create(SemaRef.<wbr>Context, DC, LocStart, Loc,<br>
DeductionGuideName, TInfo->getType(),<br>
@@ -1685,8 +1688,10 @@ private:<br>
if (Explicit)<br>
Guide->setExplicitSpecified();<br>
Guide->setRangeEnd(LocEnd);<br>
- Guide->setParams(<br>
- TInfo->getTypeLoc().castAs<<wbr>FunctionProtoTypeLoc>().<wbr>getParams());<br>
+ Guide->setParams(Params);<br>
+<br>
+ for (auto *Param : Params)<br>
+ Param->setDeclContext(Guide);<br>
<br>
auto *GuideTemplate = FunctionTemplateDecl::Create(<br>
SemaRef.Context, DC, Loc, DeductionGuideName, TemplateParams, Guide);<br>
<br>
Modified: cfe/trunk/test/SemaCXX/cxx1z-<wbr>class-template-argument-<wbr>deduction.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp?rev=295379&r1=295378&r2=295379&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/<wbr>SemaCXX/cxx1z-class-template-<wbr>argument-deduction.cpp?rev=<wbr>295379&r1=295378&r2=295379&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/SemaCXX/cxx1z-<wbr>class-template-argument-<wbr>deduction.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/cxx1z-<wbr>class-template-argument-<wbr>deduction.cpp Thu Feb 16 15:29:21 2017<br>
@@ -168,3 +168,11 @@ namespace nondeducible {<br>
typename ...B><br>
X(float) -> X<A, B...>; // ok<br>
}<br>
+<br>
+namespace default_args_from_ctor {<br>
+ template <class A> struct S { S(A = 0) {} };<br>
+ S s(0);<br>
+<br>
+ template <class A> struct T { template<typename B> T(A = 0, B = 0) {} };<br>
+ T t(0, 0);<br>
+}<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>