llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Younan Zhang (zyn0217) <details> <summary>Changes</summary> It turns out that PackIndexingExpr doesn't create any PackExpansionTypes for unexpanded packs and thus we don't have to remove the packs during the normalization. This also reverts the previous attempt f3fd5b2dd9 that doesn't completely solve the problem. Fixes #<!-- -->218548 --- Full diff: https://github.com/llvm/llvm-project/pull/218577.diff 3 Files Affected: - (modified) clang/lib/Sema/SemaConcept.cpp (+6) - (modified) clang/lib/Sema/TreeTransform.h (-4) - (modified) clang/test/SemaCXX/cxx2c-fold-exprs.cpp (+18) ``````````diff diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp index def80e274e10c..e6ef73b5a2d53 100644 --- a/clang/lib/Sema/SemaConcept.cpp +++ b/clang/lib/Sema/SemaConcept.cpp @@ -269,6 +269,12 @@ class AdjustConstraints : public TreeTransform<AdjustConstraints> { return Result; } + QualType TransformPackIndexingType(TypeLocBuilder &TLB, + PackIndexingTypeLoc TL) { + llvm::SaveAndRestore _1(RemoveNonPackExpansionPacks, false); + return inherited::TransformPackIndexingType(TLB, TL); + } + bool AlreadyTransformed(QualType T) { if (T.isNull()) return true; diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index b0c836325a971..4799f72dd6177 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -7124,10 +7124,6 @@ TreeTransform<Derived>::TransformPackIndexingType(TypeLocBuilder &TLB, for (QualType T : Types) { if (!T->containsUnexpandedParameterPack()) { - // A pack indexing type can appear in a larger pack expansion, - // e.g. `Pack...[pack_of_indexes]...` - // so we need to temporarily disable substitution of pack elements - Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), std::nullopt); QualType Transformed = getDerived().TransformType(T); if (Transformed.isNull()) return QualType(); diff --git a/clang/test/SemaCXX/cxx2c-fold-exprs.cpp b/clang/test/SemaCXX/cxx2c-fold-exprs.cpp index 79d57a6f94d58..b7b03278da54e 100644 --- a/clang/test/SemaCXX/cxx2c-fold-exprs.cpp +++ b/clang/test/SemaCXX/cxx2c-fold-exprs.cpp @@ -641,3 +641,21 @@ void f() void g() { f<long long, float>(); } } + +namespace GH218548 { + +template <class T> +concept same_as_impl = sizeof(T) == 2; +template <typename... P> +void f() requires(same_as_impl<P...[sizeof(P)]> && ...) // #GH218548_f +{} +void g() { + f<char, short, short>(); + + f<char, int, short>(); + // expected-error@-1 {{no matching function}} + // expected-note@#GH218548_f {{constraints not satisfied}} + // expected-note@#GH218548_f {{invalid index}} +} + +} `````````` </details> https://github.com/llvm/llvm-project/pull/218577 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
