class el_data
{
public:
+ /* Set of variables declared within the pattern. */
hash_set<tree> internal;
+ /* Set of AST nodes that have been visited by the traversal. */
+ hash_set<tree> visited;
+ /* List of local_specializations used within the pattern. */
tree extra;
tsubst_flags_t complain;
if (TREE_CODE (*tp) == DECL_EXPR)
data.internal.add (DECL_EXPR_DECL (*tp));
+ else if (TREE_CODE (*tp) == LAMBDA_EXPR)
+ {
+ /* Since we defer implicit capture, look in the parms and body. */
+ tree fn = lambda_function (*tp);
+ cp_walk_tree (&TREE_TYPE (fn), &extract_locals_r, &data,
+ &data.visited);
+ cp_walk_tree (&DECL_SAVED_TREE (fn), &extract_locals_r, &data,
+ &data.visited);
+ }
else if (tree spec = retrieve_local_specialization (*tp))
{
if (data.internal.contains (*tp))
extract_local_specs (tree pattern, tsubst_flags_t complain)
{
el_data data (complain);
- cp_walk_tree_without_duplicates (&pattern, extract_locals_r, &data);
+ cp_walk_tree (&pattern, extract_locals_r, &data, &data.visited);
return data.extra;
}
--- /dev/null
+// PR c++/99201
+// { dg-do compile { target c++17 } }
+
+template <typename RefF>
+ auto
+ make_tester(const RefF& reffun)
+ {
+ return [=](auto in) {
+ auto&& expected = [&](const auto&... vs) {
+ if constexpr (sizeof(in) > 0)
+ return [&](int i) { return reffun(vs[i]...); }(0);
+ else
+ return [&](int i) { return reffun(vs[i]...); }(0);
+ };
+ };
+ }
+
+int main()
+{
+ make_tester([](int x) { return x; })(0);
+ return 0;
+}