llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: cor3ntin (cor3ntin) <details> <summary>Changes</summary> A canonicalized pack indexing should refer to a canonicalized pattern Fixes #<!-- -->123033 --- Full diff: https://github.com/llvm/llvm-project/pull/123209.diff 3 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+2) - (modified) clang/lib/AST/ASTContext.cpp (+5-3) - (modified) clang/test/SemaCXX/cxx2c-pack-indexing.cpp (+23) ``````````diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index f6be841035db18..14fe920985d6a9 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -952,6 +952,8 @@ Bug Fixes to C++ Support - Fixed a crash when __PRETTY_FUNCTION__ or __FUNCSIG__ (clang-cl) appears in the trailing return type of the lambda (#GH121274) - Fixed a crash caused by the incorrect construction of template arguments for CTAD alias guides when type constraints are applied. (#GH122134) +- Fixed canonicalization of pack indexing types - Clang did not always recognized identical pack indexing. (#GH123033) + Bug Fixes to AST Handling ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index be1dd29d462788..d0ce4c511aedd0 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -6248,7 +6248,8 @@ QualType ASTContext::getPackIndexingType(QualType Pattern, Expr *IndexExpr, Canonical = getCanonicalType(Expansions[Index]); } else { llvm::FoldingSetNodeID ID; - PackIndexingType::Profile(ID, *this, Pattern, IndexExpr, FullySubstituted); + PackIndexingType::Profile(ID, *this, Pattern.getCanonicalType(), IndexExpr, + FullySubstituted); void *InsertPos = nullptr; PackIndexingType *Canon = DependentPackIndexingTypes.FindNodeOrInsertPos(ID, InsertPos); @@ -6256,8 +6257,9 @@ QualType ASTContext::getPackIndexingType(QualType Pattern, Expr *IndexExpr, void *Mem = Allocate( PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()), TypeAlignment); - Canon = new (Mem) PackIndexingType(*this, QualType(), Pattern, IndexExpr, - FullySubstituted, Expansions); + Canon = new (Mem) + PackIndexingType(*this, QualType(), Pattern.getCanonicalType(), + IndexExpr, FullySubstituted, Expansions); DependentPackIndexingTypes.InsertNode(Canon, InsertPos); } Canonical = QualType(Canon, 0); diff --git a/clang/test/SemaCXX/cxx2c-pack-indexing.cpp b/clang/test/SemaCXX/cxx2c-pack-indexing.cpp index 58b642d2735b6e..202a819655217b 100644 --- a/clang/test/SemaCXX/cxx2c-pack-indexing.cpp +++ b/clang/test/SemaCXX/cxx2c-pack-indexing.cpp @@ -321,3 +321,26 @@ namespace GH121242 { (void)z<X{}>; } } // namespace GH121242 + +namespace GH123033 { + template <class... Types> + requires __is_same_as(Types...[0], int) + void print(double d); + + template <class... Types> + requires __is_same_as(Types...[0], int) + void print(double d); + + template <class... Types> + Types...[0] convert(double d); + + template <class... Types> + Types...[0] convert(double d) { + return static_cast<Types...[0]>(d); + } + + void f() { + print<int, int>(12.34); + convert<int, int>(12.34); + } +} `````````` </details> https://github.com/llvm/llvm-project/pull/123209 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits