diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp index 9c4f52dd7150..5af5fa5c2ce8 100644 --- a/clang/lib/Sema/SemaConcept.cpp +++ b/clang/lib/Sema/SemaConcept.cpp @@ -488,6 +488,12 @@ class ConstraintSatisfactionChecker { ConceptDecl *ParentConcept = nullptr; private: + template + UnsignedOrNone getOuterPackIndex(const Constraint &C) const { + return C.getPackSubstitutionIndex() ? C.getPackSubstitutionIndex() + : PackSubstitutionIndex; + } + ExprResult EvaluateAtomicConstraint(const Expr *AtomicExpr, const MultiLevelTemplateArgumentList &MLTAL); @@ -798,14 +804,11 @@ ExprResult ConstraintSatisfactionChecker::Evaluate( unsigned Size = Satisfaction.Details.size(); llvm::FoldingSetNodeID ID; - UnsignedOrNone OuterPackSubstIndex = - Constraint.getPackSubstitutionIndex() - ? Constraint.getPackSubstitutionIndex() - : PackSubstitutionIndex; - ID.AddPointer(Constraint.getConstraintExpr()); - ID.AddInteger(OuterPackSubstIndex.toInternalRepresentation()); - HashParameterMapping(S, MLTAL, ID, OuterPackSubstIndex) + ID.AddInteger( + Constraint.getPackSubstitutionIndex().toInternalRepresentation()); + ID.AddInteger(PackSubstitutionIndex.toInternalRepresentation()); + HashParameterMapping(S, MLTAL, ID, getOuterPackIndex(Constraint)) .VisitConstraint(Constraint); if (auto Iter = S.UnsubstitutedConstraintSatisfactionCache.find(ID); @@ -1034,12 +1037,6 @@ ExprResult ConstraintSatisfactionChecker::Evaluate( const MultiLevelTemplateArgumentList &MLTAL) { const ConceptReference *ConceptId = Constraint.getConceptId(); - - UnsignedOrNone OuterPackSubstIndex = - Constraint.getPackSubstitutionIndex() - ? Constraint.getPackSubstitutionIndex() - : PackSubstitutionIndex; - Sema::InstantiatingTemplate InstTemplate( S, ConceptId->getBeginLoc(), Sema::InstantiatingTemplate::ConstraintsCheck{}, @@ -1075,8 +1072,10 @@ ExprResult ConstraintSatisfactionChecker::Evaluate( llvm::FoldingSetNodeID ID; ID.AddPointer(Constraint.getConceptId()); - ID.AddInteger(OuterPackSubstIndex.toInternalRepresentation()); - HashParameterMapping(S, MLTAL, ID, OuterPackSubstIndex) + ID.AddInteger( + Constraint.getPackSubstitutionIndex().toInternalRepresentation()); + ID.AddInteger(PackSubstitutionIndex.toInternalRepresentation()); + HashParameterMapping(S, MLTAL, ID, getOuterPackIndex(Constraint)) .VisitConstraint(Constraint); if (auto Iter = S.UnsubstitutedConstraintSatisfactionCache.find(ID); diff --git a/clang/test/SemaCXX/cxx2c-fold-exprs.cpp b/clang/test/SemaCXX/cxx2c-fold-exprs.cpp index 89ddcbaf1158..5b993fead487 100644 --- a/clang/test/SemaCXX/cxx2c-fold-exprs.cpp +++ b/clang/test/SemaCXX/cxx2c-fold-exprs.cpp @@ -508,3 +508,17 @@ static_assert(!__callable<__mdispatch>); } } + +namespace GH190169 { + +template +concept OneOf = (... || __is_same(Type, Choices)); + +template +using check = decltype((F{}(Ts{}), ...)); + +using X = check auto) {}(val); +}), char>; + +}