diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp index 719c6aab74e01..953609bfe1269 100644 --- a/clang/lib/Sema/SemaConcept.cpp +++ b/clang/lib/Sema/SemaConcept.cpp @@ -16,6 +16,7 @@ #include "clang/AST/DeclCXX.h" #include "clang/AST/ExprConcepts.h" #include "clang/AST/RecursiveASTVisitor.h" +#include "clang/AST/Type.h" #include "clang/Basic/OperatorPrecedence.h" #include "clang/Sema/EnterExpressionEvaluationContext.h" #include "clang/Sema/Initialization.h" @@ -916,6 +917,26 @@ bool Sema::CheckInstantiatedFunctionTemplateConstraints( CXXThisScopeRAII ThisScope(*this, Record, ThisQuals, Record != nullptr); LambdaScopeForCallOperatorInstantiationRAII LambdaScope( *this, const_cast(Decl), *MLTAL, Scope); + // auto parent = Decl->getParent(); + // while (parent) { + // if (auto *TD = dyn_cast(parent)) { + // for (auto P : TemplateAC) { + // if (P->isValueDependent()) { + // return false; + // } + // } + // } + // parent = parent->getParent(); + // // if (parent->getDeclKind() == Decl::Decla) { + // // } + // } + // Check the number of the Concept template parameters + // for (auto P : TemplateAC) { + // // const TemplateTypeParmDecl *CD = dyn_cast(P); + // if (!P->isValueDependent()) { + // return false; + // } + // } llvm::SmallVector Converted; return CheckConstraintSatisfaction(Template, TemplateAC, Converted, *MLTAL, diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index 699e0985e595b..954ca488a07ec 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -4349,6 +4349,23 @@ Sema::TemplateDeductionResult Sema::DeduceTemplateArguments( return Result; } + const auto *Proto = Function->getType()->castAs(); + if (!Proto->isTemplateVariadic()) { + size_t params = 0, deducedParams = 0; + for(auto P : *TemplateParams) { + const TemplateTypeParmDecl *CD = dyn_cast(P); + if(CD && CD->hasTypeConstraint()) { + params++; + } + } + for( auto P : Deduced ) { + deducedParams++; + } + + if( params > deducedParams ) { + return TDK_Invalid; + } + } // Capture the context in which the function call is made. This is the context // that is needed when the accessibility of template arguments is checked. DeclContext *CallingCtx = CurContext; diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 1ad843d0bf4e0..9d91fabb5af04 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -6439,6 +6439,29 @@ QualType TreeTransform::TransformDecltypeType(TypeLocBuilder &TLB, SemaRef, Sema::ExpressionEvaluationContext::Unevaluated, nullptr, Sema::ExpressionEvaluationContextRecord::EK_Decltype); + // while(auto EE = T->getUnderlyingExpr()){} + // if (EE->isInstantiationDependent()) { + + // // Check the number of the Concept template parameters + // size_t conceptParams = 0; + // if (auto lambdaExpr = dyn_cast(EE)) { + // if (lambdaExpr->getTemplateParameterList()) { + // for (auto P : *lambdaExpr->getTemplateParameterList()) { + // const TemplateTypeParmDecl *CD = dyn_cast(P); + // if (CD && CD->hasTypeConstraint()) { + // conceptParams++; + // } + // } + + // if (conceptParams > 0 && + // conceptParams == lambdaExpr->getTemplateParameterList()->size()) + // { + // return QualType(); + // } + // } + // } + // } + ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr()); if (E.isInvalid()) return QualType();