[clang] [Clang] Add captures to the instantiation scope for noexcept specifiers (PR #97166)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 6 18:58:23 PDT 2024
================
@@ -60,3 +60,26 @@ template<class T1> C1<X<X<T1>>> auto t3() {
template C1<X<X<int>>> auto t3<int>();
static_assert(is_same<decltype(t3<int>()), X<X<X<int>>>>);
#endif
+
+namespace GH95735 {
+
+int g(int fn) {
+ return [f = fn](auto tpl) noexcept(noexcept(f)) { return f; }(0);
+}
+
+int foo(auto... fn) {
+ // FIXME: This one hits the assertion "if the exception specification is dependent,
+ // then the noexcept expression should be value-dependent" in the constructor of
+ // FunctionProtoType.
+ // One possible solution is to update Sema::canThrow() to consider expressions
+ // (e.g. DeclRefExpr/FunctionParmPackExpr) involving unexpanded parameters as Dependent.
+ // This would effectively add an extra value-dependent flag to the noexcept expression.
+ // However, I'm afraid that would also cause ABI breakage.
+ // [...f = fn](auto tpl) noexcept(noexcept(f)) { return 0; }(0);
----------------
zyn0217 wrote:
We have that check: with a non-assertion build, we would correctly diagnose against the unexpanded pack here.
However, that check happens after we form a FunctionProtoType, where an assertion would have been encountered.
https://github.com/llvm/llvm-project/pull/97166
More information about the cfe-commits
mailing list