int flags /* = LOOKUP_NORMAL */,
tree tmpl /* = NULL_TREE */)
{
- if (init == error_mark_node)
+ if (type == error_mark_node || init == error_mark_node)
return error_mark_node;
if (init && type_dependent_expression_p (init)
auto_node. */
complain &= ~tf_partial;
+ if (init && BRACE_ENCLOSED_INITIALIZER_P (init))
+ {
+ /* We don't recurse here because we can't deduce from a nested
+ initializer_list. */
+ if (CONSTRUCTOR_ELTS (init))
+ for (constructor_elt &elt : CONSTRUCTOR_ELTS (init))
+ elt.value = resolve_nondeduced_context (elt.value, complain);
+ }
+ else if (init)
+ init = resolve_nondeduced_context (init, complain);
+
/* In C++23, we must deduce the type to int&& for code like
decltype(auto) f(int&& x) { return (x); }
or
}
}
- if (type == error_mark_node)
+ if (type == error_mark_node || init == error_mark_node)
return error_mark_node;
- if (BRACE_ENCLOSED_INITIALIZER_P (init))
- {
- /* We don't recurse here because we can't deduce from a nested
- initializer_list. */
- if (CONSTRUCTOR_ELTS (init))
- for (constructor_elt &elt : CONSTRUCTOR_ELTS (init))
- elt.value = resolve_nondeduced_context (elt.value, complain);
- }
- else
- init = resolve_nondeduced_context (init, complain);
-
tree targs;
if (context == adc_decomp_type
&& auto_node == type
- && init != error_mark_node
&& TREE_CODE (TREE_TYPE (init)) == ARRAY_TYPE)
{
/* [dcl.struct.bind]/1 - if decomposition declaration has no ref-qualifiers
--- /dev/null
+// PR c++/106214
+// { dg-do compile { target c++17 } }
+// A version of cpp0x/initlist-deduce3.C using list CTAD instead
+// of ordinary auto deduction from an initializer list.
+
+using size_t = decltype(sizeof 0);
+
+namespace std {
+ template<typename T> struct initializer_list {
+ const T *ptr;
+ size_t n;
+ initializer_list(const T*, size_t);
+ };
+}
+
+template<typename T>
+void Task() {}
+
+template<class T>
+struct vector {
+ vector(std::initializer_list<T>);
+};
+
+vector a = &Task<int>; // { dg-error "deduction|no match" }
+vector b = { &Task<int> };
+vector e{ &Task<int> };
+vector f = { &Task<int>, &Task<int> };
+vector d = { static_cast<void(*)()>(&Task<int>) };