Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
8 changes: 5 additions & 3 deletions clang/lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6248,16 +6248,18 @@ 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);
if (!Canon) {
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);
Expand Down
23 changes: 23 additions & 0 deletions clang/test/SemaCXX/cxx2c-pack-indexing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Loading