diff options
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiateDecl.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 28 | 
1 files changed, 25 insertions, 3 deletions
| diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 64500d0a26d54..fbbab8f007039 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -1848,6 +1848,8 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(    // FIXME: Concepts: Do not substitute into constraint expressions    Expr *TrailingRequiresClause = D->getTrailingRequiresClause();    if (TrailingRequiresClause) { +    EnterExpressionEvaluationContext ConstantEvaluated( +        SemaRef, Sema::ExpressionEvaluationContext::Unevaluated);      ExprResult SubstRC = SemaRef.SubstExpr(TrailingRequiresClause,                                             TemplateArgs);      if (SubstRC.isInvalid()) @@ -2186,6 +2188,8 @@ Decl *TemplateDeclInstantiator::VisitCXXMethodDecl(    // FIXME: Concepts: Do not substitute into constraint expressions    Expr *TrailingRequiresClause = D->getTrailingRequiresClause();    if (TrailingRequiresClause) { +    EnterExpressionEvaluationContext ConstantEvaluated( +        SemaRef, Sema::ExpressionEvaluationContext::Unevaluated);      ExprResult SubstRC = SemaRef.SubstExpr(TrailingRequiresClause,                                             TemplateArgs);      if (SubstRC.isInvalid()) @@ -2685,6 +2689,16 @@ Decl *TemplateDeclInstantiator::VisitNonTypeTemplateParmDecl(          D->getDepth() - TemplateArgs.getNumSubstitutedLevels(),          D->getPosition(), D->getIdentifier(), T, D->isParameterPack(), DI); +  if (AutoTypeLoc AutoLoc = DI->getTypeLoc().getContainedAutoTypeLoc()) +    if (AutoLoc.isConstrained()) +      if (SemaRef.AttachTypeConstraint( +              AutoLoc, Param, +              IsExpandedParameterPack +                ? DI->getTypeLoc().getAs<PackExpansionTypeLoc>() +                    .getEllipsisLoc() +                : SourceLocation())) +        Invalid = true; +    Param->setAccess(AS_public);    Param->setImplicit(D->isImplicit());    if (Invalid) @@ -3600,6 +3614,12 @@ Decl *TemplateDeclInstantiator::VisitConceptDecl(ConceptDecl *D) {    llvm_unreachable("Concept definitions cannot reside inside a template");  } +Decl * +TemplateDeclInstantiator::VisitRequiresExprBodyDecl(RequiresExprBodyDecl *D) { +  return RequiresExprBodyDecl::Create(SemaRef.Context, D->getDeclContext(), +                                      D->getBeginLoc()); +} +  Decl *TemplateDeclInstantiator::VisitDecl(Decl *D) {    llvm_unreachable("Unexpected decl");  } @@ -3713,6 +3733,8 @@ TemplateDeclInstantiator::SubstTemplateParams(TemplateParameterList *L) {    // checking satisfaction.    Expr *InstRequiresClause = nullptr;    if (Expr *E = L->getRequiresClause()) { +    EnterExpressionEvaluationContext ConstantEvaluated( +        SemaRef, Sema::ExpressionEvaluationContext::Unevaluated);      ExprResult Res = SemaRef.SubstExpr(E, TemplateArgs);      if (Res.isInvalid() || !Res.isUsable()) {        return nullptr; @@ -4236,9 +4258,9 @@ bool Sema::CheckInstantiatedFunctionTemplateConstraints(          MLTAL.getInnermost(), SourceRange());      if (Inst.isInvalid())        return true; -    if (addInstantiatedParametersToScope(*this, Decl, -                                        Decl->getTemplateInstantiationPattern(), -                                         Scope, MLTAL)) +    if (addInstantiatedParametersToScope( +            *this, Decl, Decl->getPrimaryTemplate()->getTemplatedDecl(), +            Scope, MLTAL))        return true;    } | 
