Lancern created this revision. Lancern added reviewers: Richard, smith. Herald added a project: All. Lancern requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
When checking constraint satisfaction on template arguments, the outer template levels are not added to MultiLevelTemplateArgumentList. Fix bugs https://github.com/llvm/llvm-project/issues/50845 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D128351 Files: clang/lib/Sema/SemaConcept.cpp clang/test/Sema/template-member-constraint.cpp Index: clang/test/Sema/template-member-constraint.cpp =================================================================== --- /dev/null +++ clang/test/Sema/template-member-constraint.cpp @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 %s -std=c++20 -fsyntax-only -verify + +template <typename T> +concept Foo = true; + +template <typename T, typename U> +struct Bar {}; + +template <typename T> +struct Baz { + template <Foo U> + using BazBar = Bar<T, U>; + + using BazBarInt = BazBar<int>; // expected-no-diagnostics +}; + +template <typename urng_t> +struct contiguous_range { + template <bool const_range> + requires(const_range == false) + using basic_iterator = int; + + auto begin() { + return basic_iterator<false>{}; // expected-no-diagnostics + } +}; Index: clang/lib/Sema/SemaConcept.cpp =================================================================== --- clang/lib/Sema/SemaConcept.cpp +++ clang/lib/Sema/SemaConcept.cpp @@ -293,6 +293,7 @@ MultiLevelTemplateArgumentList MLTAL; MLTAL.addOuterTemplateArguments(TemplateArgs); + MLTAL.addOuterRetainedLevels(Template->getTemplateDepth()); for (const Expr *ConstraintExpr : ConstraintExprs) { if (calculateConstraintSatisfaction(S, Template, TemplateArgs,
Index: clang/test/Sema/template-member-constraint.cpp =================================================================== --- /dev/null +++ clang/test/Sema/template-member-constraint.cpp @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 %s -std=c++20 -fsyntax-only -verify + +template <typename T> +concept Foo = true; + +template <typename T, typename U> +struct Bar {}; + +template <typename T> +struct Baz { + template <Foo U> + using BazBar = Bar<T, U>; + + using BazBarInt = BazBar<int>; // expected-no-diagnostics +}; + +template <typename urng_t> +struct contiguous_range { + template <bool const_range> + requires(const_range == false) + using basic_iterator = int; + + auto begin() { + return basic_iterator<false>{}; // expected-no-diagnostics + } +}; Index: clang/lib/Sema/SemaConcept.cpp =================================================================== --- clang/lib/Sema/SemaConcept.cpp +++ clang/lib/Sema/SemaConcept.cpp @@ -293,6 +293,7 @@ MultiLevelTemplateArgumentList MLTAL; MLTAL.addOuterTemplateArguments(TemplateArgs); + MLTAL.addOuterRetainedLevels(Template->getTemplateDepth()); for (const Expr *ConstraintExpr : ConstraintExprs) { if (calculateConstraintSatisfaction(S, Template, TemplateArgs,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits