tp = &TYPE_NAME (*tp);
if (TREE_CODE (*tp) == DECL_EXPR)
- data.internal.add (DECL_EXPR_DECL (*tp));
+ {
+ tree decl = DECL_EXPR_DECL (*tp);
+ data.internal.add (decl);
+ if (VAR_P (decl)
+ && DECL_DECOMPOSITION_P (decl)
+ && TREE_TYPE (decl) != error_mark_node)
+ {
+ gcc_assert (DECL_NAME (decl) == NULL_TREE);
+ for (tree decl2 = DECL_CHAIN (decl);
+ decl2
+ && VAR_P (decl2)
+ && DECL_DECOMPOSITION_P (decl2)
+ && DECL_NAME (decl2)
+ && TREE_TYPE (decl2) != error_mark_node;
+ decl2 = DECL_CHAIN (decl2))
+ {
+ gcc_assert (DECL_DECOMP_BASE (decl2) == decl);
+ data.internal.add (decl2);
+ }
+ }
+ }
else if (TREE_CODE (*tp) == LAMBDA_EXPR)
{
/* Since we defer implicit capture, look in the parms and body. */
--- /dev/null
+// PR c++/99833
+// { dg-do compile { target c++17 } }
+
+struct S { int a, b; };
+template <class>
+void
+foo ()
+{
+ [](auto d) { if constexpr (auto [a, b]{d}; sizeof (a) > 0) a++; } (S{});
+}
+template void foo<S> ();
--- /dev/null
+// PR c++/99833
+// { dg-do compile { target c++20 } }
+
+#include <tuple>
+
+auto f(auto&& x)
+{
+ [&](auto...) {
+ auto y = std::tuple{ "what's happening here?", x };
+ if constexpr (auto [_, z] = y; requires { z; })
+ return;
+ }();
+}
+
+int main()
+{
+ f(42);
+}