[clang] [Sema] Preserve ContainsUnexpandedParameterPack in TransformLambdaExpr (PR #86265)
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 18 09:23:58 PDT 2024
================
@@ -23,3 +23,104 @@ namespace PR41576 {
}
static_assert(f(3, 4) == 6); // expected-note {{instantiation}}
}
+
+namespace PR85667 {
+
+template <class T>
+struct identity {
+ using type = T;
+};
+
+template <class = void> void f() {
+
+ static_assert([]<class... Is>(Is... x) {
+ return ([I(x)] {
+ return I;
+ }() + ...);
+ }(1, 2) == 3);
+
+ static_assert([]<class... Is>(Is... x) {
+ return ([](auto y = Is()) { return y + 1; } + ...);
+ }(0, 0, 0) == 3);
+
+ []<class... Is>() {
+ return ([]() noexcept(Is()) { return 0; }() + ...);
+ }.template operator()<int, int>();
+
+ static_assert(__is_same(decltype([]<class... Is>() {
+ return ([]() -> decltype(Is()) { return {}; }(),
+ ...);
+ }.template operator()<int, char>()),
+ char));
+
+ []<class... Is>() {
+ return ([]<class... Ts>() -> decltype(Is()) { return Ts(); }() + ...);
+ // expected-error at -1 {{unexpanded parameter pack 'Ts'}}
+ }.template operator()<int, int>();
+
+ // Note that GCC and EDG reject this case currently.
+ // GCC says the fold expression "has no unexpanded parameter packs", while
+ // EDG says the constraint is not allowed on a non-template function.
+ // MSVC is happy with it.
+ []<class... Is>() {
+ ([]()
+ requires(Is())
+ {},
+ ...);
+ }.template operator()<bool, bool>();
+
+ // https://github.com/llvm/llvm-project/issues/56852
+ []<class... Is>(Is...) {
+ ([] {
+ using T = identity<Is>::type;
+ }(), ...);
+ }(1, 2);
+
+ [](auto ...y) {
+ ([y] { }(), ...);
+ }();
+
+ [](auto ...x) {
+ ([&](auto ...y) {
+ ([x..., y] { }(), ...);
+ })(1);
+ }(2, 'b');
+
+#if 0
+ // https://github.com/llvm/llvm-project/issues/18873
+ [](auto ...x) { // #1
+ ([&](auto ...y) { // #2
+ ([x, y] { }(), ...); // #3
+ })(1, 'a'); // #4
+ }(2, 'b'); // #5
+
----------------
mizvekov wrote:
I am not opposed to adding disabled crash repros as tests, for future fixes, but these should be clearly marked with a FIXME.
https://github.com/llvm/llvm-project/pull/86265
More information about the cfe-commits
mailing list