Skip to content

Commit bda66af

Browse files
committed
[Clang] Correctly propagate type aliases' unexpanded flags up to lambda
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.
1 parent 9190e1c commit bda66af

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ Bug Fixes to C++ Support
810810
module imports in those situations. (#GH60336)
811811
- Fix init-capture packs having a size of one before being instantiated. (#GH63677)
812812
- Clang now preserves the unexpanded flag in a lambda transform used for pack expansion. (#GH56852), (#GH85667),
813-
(#GH99877).
813+
(#GH99877), (#GH122417).
814814
- Fixed a bug when diagnosing ambiguous explicit specializations of constrained member functions.
815815
- Fixed an assertion failure when selecting a function from an overload set that includes a
816816
specialization of a conversion function template.

clang/lib/Sema/TreeTransform.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8496,7 +8496,7 @@ TreeTransform<Derived>::TransformDeclStmt(DeclStmt *S) {
84968496
getSema()
84978497
.getASTContext()
84988498
.getTypeDeclType(TD)
8499-
.getCanonicalType()
8499+
.getSingleStepDesugaredType(getSema().getASTContext())
85008500
->containsUnexpandedParameterPack();
85018501

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

clang/test/SemaCXX/fold_lambda_with_variadics.cpp

Lines changed: 6 additions & 0 deletions
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)