Skip to content

Commit b311ab0

Browse files
authored
[Clang] Fix canonicalization of pack indexing types (#123209)
A canonicalized pack indexing should refer to a canonicalized pattern Fixes #123033
1 parent 09bf5b0 commit b311ab0

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,8 @@ Bug Fixes to C++ Support
952952
- Fixed a crash when __PRETTY_FUNCTION__ or __FUNCSIG__ (clang-cl) appears in the trailing return type of the lambda (#GH121274)
953953
- Fixed a crash caused by the incorrect construction of template arguments for CTAD alias guides when type
954954
constraints are applied. (#GH122134)
955+
- Fixed canonicalization of pack indexing types - Clang did not always recognized identical pack indexing. (#GH123033)
956+
955957

956958
Bug Fixes to AST Handling
957959
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/AST/ASTContext.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6248,16 +6248,18 @@ QualType ASTContext::getPackIndexingType(QualType Pattern, Expr *IndexExpr,
62486248
Canonical = getCanonicalType(Expansions[Index]);
62496249
} else {
62506250
llvm::FoldingSetNodeID ID;
6251-
PackIndexingType::Profile(ID, *this, Pattern, IndexExpr, FullySubstituted);
6251+
PackIndexingType::Profile(ID, *this, Pattern.getCanonicalType(), IndexExpr,
6252+
FullySubstituted);
62526253
void *InsertPos = nullptr;
62536254
PackIndexingType *Canon =
62546255
DependentPackIndexingTypes.FindNodeOrInsertPos(ID, InsertPos);
62556256
if (!Canon) {
62566257
void *Mem = Allocate(
62576258
PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
62586259
TypeAlignment);
6259-
Canon = new (Mem) PackIndexingType(*this, QualType(), Pattern, IndexExpr,
6260-
FullySubstituted, Expansions);
6260+
Canon = new (Mem)
6261+
PackIndexingType(*this, QualType(), Pattern.getCanonicalType(),
6262+
IndexExpr, FullySubstituted, Expansions);
62616263
DependentPackIndexingTypes.InsertNode(Canon, InsertPos);
62626264
}
62636265
Canonical = QualType(Canon, 0);

clang/test/SemaCXX/cxx2c-pack-indexing.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,3 +321,26 @@ namespace GH121242 {
321321
(void)z<X{}>;
322322
}
323323
} // namespace GH121242
324+
325+
namespace GH123033 {
326+
template <class... Types>
327+
requires __is_same_as(Types...[0], int)
328+
void print(double d);
329+
330+
template <class... Types>
331+
requires __is_same_as(Types...[0], int)
332+
void print(double d);
333+
334+
template <class... Types>
335+
Types...[0] convert(double d);
336+
337+
template <class... Types>
338+
Types...[0] convert(double d) {
339+
return static_cast<Types...[0]>(d);
340+
}
341+
342+
void f() {
343+
print<int, int>(12.34);
344+
convert<int, int>(12.34);
345+
}
346+
}

0 commit comments

Comments
 (0)