r295379 - Properly set up the DeclContext for parameters of implicit deduction guides;

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 16 21:17:29 PST 2017


Hi Richard,

One more issue. When compiling with `-g` the following code hits a
`llvm_unreachable` in CGDebugInfo::CreateTypeNode.

template <class T> struct S { S(T) {} };
S s(42);

/Eric

On Thu, Feb 16, 2017 at 2:29 PM, Richard Smith via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> 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);
> +}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170216/78f52899/attachment.html>


More information about the cfe-commits mailing list