llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: cor3ntin (cor3ntin)

<details>
<summary>Changes</summary>

Fixes #<!-- -->48937

---
Full diff: https://github.com/llvm/llvm-project/pull/98496.diff


3 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+3-1) 
- (modified) clang/lib/Sema/SemaLambda.cpp (+1) 
- (modified) clang/test/SemaCXX/lambda-pack-expansion.cpp (+21) 


``````````diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6adf57da42e65..c6a2237113ace 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -103,7 +103,7 @@ ABI Changes in This Version
   ifuncs. Its purpose was to preserve backwards compatibility when the ".ifunc"
   suffix got removed from the name mangling. The alias interacts badly with
   GlobalOpt (see the issue #96197).
-  
+
 - Fixed Microsoft name mangling for auto non-type template arguments of pointer
   type for MSVC 1920+. This change resolves incompatibilities with code 
compiled
   by MSVC 1920+ but will introduce incompatibilities with code compiled by
@@ -1024,6 +1024,8 @@ Bug Fixes to C++ Support
 - Fixed a bug where references to lambda capture inside a ``noexcept`` 
specifier were not correctly
   instantiated. (#GH95735).
 - Fixed a CTAD substitution bug involving type aliases that reference outer 
template parameters. (#GH94614).
+- Clang now correctly handles unexpanded packs in the template parameter list 
of a generic lambda expression
+  (#GH48937)
 
 Bug Fixes to AST Handling
 ^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index 4b19296e8a23a..7b93e5df25b36 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -1380,6 +1380,7 @@ void Sema::ActOnLambdaClosureParameters(
     AddTemplateParametersToLambdaCallOperator(LSI->CallOperator, LSI->Lambda,
                                               TemplateParams);
     LSI->Lambda->setLambdaIsGeneric(true);
+    LSI->ContainsUnexpandedParameterPack |= 
TemplateParams->containsUnexpandedParameterPack();
   }
   LSI->AfterParameterList = true;
 }
diff --git a/clang/test/SemaCXX/lambda-pack-expansion.cpp 
b/clang/test/SemaCXX/lambda-pack-expansion.cpp
index e3e968e2704ed..221d1d01a06ae 100644
--- a/clang/test/SemaCXX/lambda-pack-expansion.cpp
+++ b/clang/test/SemaCXX/lambda-pack-expansion.cpp
@@ -20,3 +20,24 @@ void foo() {
   take_by_ref(x);
 }
 }
+
+namespace GH48937 {
+
+template <typename... Ts>
+consteval int f(Ts... ts) {
+  return ([]<Ts a = 42>(){ return a;}, ...)();
+}
+
+static_assert(f(0, 42) == 42);
+
+template <typename Ts>
+int g(Ts ts) {
+  return ([]<Ts a = 42>(){ return a;}, ...)();  // expected-error {{pack 
expansion does not contain any unexpanded parameter packs}}
+}
+
+template <typename... Ts>
+int h(Ts... ts) {
+  return ([]<Ts a = 42>(){ return a;})();  // expected-error {{expression 
contains unexpanded parameter pack 'Ts'}}
+}
+
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/98496
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to