tsubst_flags_t complain, auto_deduction_context context,
tree outer_targs, int flags)
{
- tree targs;
-
if (init == error_mark_node)
return error_mark_node;
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.decomp]/1 - if decomposition declaration has no ref-qualifiers
- and initializer has array type, deduce cv-qualified array type. */
- return cp_build_qualified_type_real (TREE_TYPE (init), TYPE_QUALS (type),
- complain);
+ {
+ /* [dcl.struct.bind]/1 - if decomposition declaration has no ref-qualifiers
+ and initializer has array type, deduce cv-qualified array type. */
+ targs = make_tree_vec (1);
+ TREE_VEC_ELT (targs, 0) = TREE_TYPE (init);
+ }
else if (AUTO_IS_DECLTYPE (auto_node))
{
tree stripped_init = tree_strip_any_location_wrapper (init);
if (processing_template_decl)
{
gcc_checking_assert (context == adc_variable_type
- || context == adc_return_type);
+ || context == adc_return_type
+ || context == adc_decomp_type);
gcc_checking_assert (!type_dependent_expression_p (init));
/* If the constraint is dependent, we need to wait until
instantiation time to resolve the placeholder. */
return type;
}
- if ((context == adc_return_type || context == adc_variable_type)
+ if ((context == adc_return_type
+ || context == adc_variable_type
+ || context == adc_decomp_type)
&& current_function_decl
&& DECL_TEMPLATE_INFO (current_function_decl))
outer_targs = DECL_TI_ARGS (current_function_decl);
--- /dev/null
+// PR c++/99899
+// { dg-do compile { target c++20 } }
+
+template <class T> concept C1 = sizeof(T) > sizeof(int[1]);
+
+template <class>
+void f() {
+ int x[] = {1,2};
+ int y[] = {3};
+ C1 auto [a,b] = x;
+ C1 auto [c] = y; // { dg-error "constraints" }
+}
+
+template <class T>
+void g() {
+ T x[] = {1,2};
+ T y[] = {3};
+ C1 auto [a,b] = x;
+ C1 auto [c] = y; // { dg-error "constraints" }
+}
+template void g<int>();
+
+
+template <class... Ts> concept C2 = sizeof...(Ts) > 1;
+
+struct S { int a, b; } s;
+
+template <class T>
+void h() {
+ const C2<T> auto& [a, b] = s;
+}
+template void h<int>();