Skip to content

Commit 6f0a627

Browse files
authored
[Clang] Correctly propagate type aliases' unexpanded flags up to lambda (#122875)
We should have been checking desugar() for the type of the right-hand side of a typedef declaration, instead of using getCanonicalType(), which points to the end of the type alias chain. Fixes #122417
1 parent 0b1ae89 commit 6f0a627

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

clang/docs/ReleaseNotes.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ Bug Fixes to C++ Support
860860
module imports in those situations. (#GH60336)
861861
- Fix init-capture packs having a size of one before being instantiated. (#GH63677)
862862
- Clang now preserves the unexpanded flag in a lambda transform used for pack expansion. (#GH56852), (#GH85667),
863-
(#GH99877).
863+
(#GH99877), (#GH122417).
864864
- Fixed a bug when diagnosing ambiguous explicit specializations of constrained member functions.
865865
- Fixed an assertion failure when selecting a function from an overload set that includes a
866866
specialization of a conversion function template.

clang/lib/Sema/TreeTransform.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -8499,7 +8499,7 @@ TreeTransform<Derived>::TransformDeclStmt(DeclStmt *S) {
84998499
getSema()
85008500
.getASTContext()
85018501
.getTypeDeclType(TD)
8502-
.getCanonicalType()
8502+
.getSingleStepDesugaredType(getSema().getASTContext())
85038503
->containsUnexpandedParameterPack();
85048504

85058505
if (auto *VD = dyn_cast<VarDecl>(Transformed))

clang/test/SemaCXX/fold_lambda_with_variadics.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ struct identity {
77
using type = T;
88
};
99

10+
template <class> using ElementType = int;
11+
1012
template <class = void> void f() {
1113

1214
static_assert([]<class... Is>(Is... x) {
@@ -47,6 +49,10 @@ template <class = void> void f() {
4749
}(), ...);
4850
}(1, 2);
4951

52+
[]<class... Is>(Is...) {
53+
([] { using T = ElementType<Is>; }(), ...);
54+
}(1);
55+
5056
[](auto ...y) {
5157
([y] { }(), ...);
5258
}();

0 commit comments

Comments
 (0)