llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: cor3ntin (cor3ntin) <details> <summary>Changes</summary> When a pack in a pack indexing specifier cannot be immediately expanded, we were creating an incomplete TypeLoc (causing assertion failure). As we do not keep track of typelocs of expanded elements, we create a trivial typeloc Fixes #<!-- -->81697 --- Full diff: https://github.com/llvm/llvm-project/pull/82234.diff 2 Files Affected: - (modified) clang/lib/Sema/TreeTransform.h (+3-1) - (modified) clang/test/SemaCXX/cxx2c-pack-indexing.cpp (+19) ``````````diff diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index a32a585531873a..964ddeefc5a088 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -6561,7 +6561,9 @@ TreeTransform<Derived>::TransformPackIndexingType(TypeLocBuilder &TLB, return QualType(); if (!ShouldExpand) { Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1); - QualType Pack = getDerived().TransformType(T); + // FIXME: should we keep TypeLoc for individual expansions in PackIndexingTypeLoc? + TypeSourceInfo* TI = SemaRef.getASTContext().getTrivialTypeSourceInfo(T, TL.getBeginLoc()); + QualType Pack = getDerived().TransformType(TLB, TI->getTypeLoc()); if (Pack.isNull()) return QualType(); if (NotYetExpanded) { diff --git a/clang/test/SemaCXX/cxx2c-pack-indexing.cpp b/clang/test/SemaCXX/cxx2c-pack-indexing.cpp index 625a56031598b7..e13635383b6ca6 100644 --- a/clang/test/SemaCXX/cxx2c-pack-indexing.cpp +++ b/clang/test/SemaCXX/cxx2c-pack-indexing.cpp @@ -135,3 +135,22 @@ using Splice = typename SpliceImpl<Tl, Il>::type; using type = Splice<TL<char, short, long, double>, IL<1, 2>>; static_assert(is_same<type, TL<short, long>>); } + + +namespace GH81697 { + +template<class... Ts> struct tuple { + int __x0; +}; + +template<auto I, class... Ts> +Ts...[I]& get(tuple<Ts...>& t) { + return t.__x0; +} + +void f() { + tuple<int> x; + get<0>(x); +} + +} `````````` </details> https://github.com/llvm/llvm-project/pull/82234 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits